|
|
@@ -1,8 +1,10 @@
|
|
1
|
1
|
package api.controller.patient;
|
|
2
|
2
|
|
|
|
3
|
+import api.entity.database.patient.Label;
|
|
3
|
4
|
import api.entity.database.patient.Patient;
|
|
4
|
5
|
import api.entity.database.patient.PatientLog;
|
|
5
|
6
|
import api.entity.input.patient.LabelInput;
|
|
|
7
|
+import api.service.patient.ILabelService;
|
|
6
|
8
|
import api.service.patient.IPatientLogService;
|
|
7
|
9
|
import api.service.patient.IPatientService;
|
|
8
|
10
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -38,13 +40,16 @@ public class PatientLabelController extends BaseController {
|
|
38
|
40
|
@Autowired
|
|
39
|
41
|
private IPatientService patientService;
|
|
40
|
42
|
|
|
|
43
|
+ @Autowired
|
|
|
44
|
+ private ILabelService labelService;
|
|
|
45
|
+
|
|
41
|
46
|
@ApiOperation("列表")
|
|
42
|
47
|
@Log(title = "查询p_patientlabel列表",businessType = BusinessType.QUERY)
|
|
43
|
48
|
@GetMapping
|
|
44
|
49
|
public AjaxResult getList(PatientLabel input, PageInput pageInput) {
|
|
45
|
50
|
LambdaQueryWrapper<PatientLabel> qw = new LambdaQueryWrapper();
|
|
46
|
|
- qw.eq(input.getLabelId() != null && input.getLabelId() > 0, PatientLabel::getLabelId, input.getLabelId());
|
|
47
|
|
- qw.like(!StringHelper.isEmpty(input.getPatientId()), PatientLabel::getPatientId, input.getPatientId());
|
|
|
51
|
+ qw.eq(input.getLabelId() != null , PatientLabel::getLabelId, input.getLabelId());
|
|
|
52
|
+ qw.eq(!StringHelper.isEmpty(input.getPatientId()), PatientLabel::getPatientId, input.getPatientId());
|
|
48
|
53
|
qw.like(!StringHelper.isEmpty(input.getPatientName()), PatientLabel::getPatientName, input.getPatientName());
|
|
49
|
54
|
qw.like(!StringHelper.isEmpty(input.getPhoneNumber()), PatientLabel::getPhoneNumber, input.getPhoneNumber());
|
|
50
|
55
|
qw.like(!StringHelper.isEmpty(input.getLabelName()), PatientLabel::getLabelName, input.getLabelName());
|
|
|
@@ -71,6 +76,8 @@ public class PatientLabelController extends BaseController {
|
|
71
|
76
|
@Log(title = "新增p_patientlabel",businessType = BusinessType.INSERT)
|
|
72
|
77
|
@PostMapping
|
|
73
|
78
|
public AjaxResult add(@RequestBody PatientLabel input) {
|
|
|
79
|
+
|
|
|
80
|
+
|
|
74
|
81
|
Date currentDate = new Date(System.currentTimeMillis());
|
|
75
|
82
|
input.setCreateTime(currentDate);
|
|
76
|
83
|
input.setCreateUserName(CurrentUser().getNickName());
|
|
|
@@ -118,7 +125,8 @@ public class PatientLabelController extends BaseController {
|
|
118
|
125
|
|
|
119
|
126
|
LambdaQueryWrapper<PatientLabel> lp = new LambdaQueryWrapper<>();
|
|
120
|
127
|
lp.in(PatientLabel::getPatientId, patientids);
|
|
121
|
|
- lp.eq(PatientLabel::getLabelName, input.getLabelName());
|
|
|
128
|
+
|
|
|
129
|
+ lp.eq(PatientLabel::getLabelId, input.getLabelId());
|
|
122
|
130
|
boolean result = patientlabelService.delete(lp);
|
|
123
|
131
|
if (result) {
|
|
124
|
132
|
//删除标签 存log记录
|
|
|
@@ -142,14 +150,26 @@ public class PatientLabelController extends BaseController {
|
|
142
|
150
|
@ApiOperation("批量打标签")
|
|
143
|
151
|
@Log(title = "新增p_patientlabel",businessType = BusinessType.INSERT)
|
|
144
|
152
|
@PostMapping("/batchadd")
|
|
145
|
|
- // public AjaxResult batchadd(@PathVariable List<String> patientids, @PathVariable String labelname) {
|
|
|
153
|
+
|
|
146
|
154
|
public AjaxResult batchadd(@RequestBody LabelInput inputlabel) {
|
|
|
155
|
+ Label labelmodel=new Label();
|
|
|
156
|
+ if(inputlabel.getLabelId()!=null && inputlabel.getLabelId()>0){}
|
|
|
157
|
+ else{
|
|
|
158
|
+ //先添加标签
|
|
|
159
|
+ labelmodel.setLabelName(inputlabel.getLabelName());
|
|
|
160
|
+ labelmodel.setPatientCount(inputlabel.getPatientids().stream().count());
|
|
|
161
|
+ labelmodel.setCreateUser(CurrentUser().getUserName());
|
|
|
162
|
+ labelService.insert(labelmodel);
|
|
|
163
|
+ }
|
|
|
164
|
+
|
|
147
|
165
|
Date currentDate = new Date(System.currentTimeMillis());
|
|
148
|
166
|
List<String> patientids= inputlabel.getPatientids();
|
|
149
|
167
|
LambdaQueryWrapper<Patient> lp=new LambdaQueryWrapper<>();
|
|
150
|
168
|
lp.in(Patient::getPatientId,inputlabel.getPatientids());
|
|
151
|
169
|
List<Patient> patientList= patientService.getList(lp);
|
|
152
|
170
|
|
|
|
171
|
+ Long labelid=inputlabel.getLabelId()==null?labelmodel.getLabelId():inputlabel.getLabelId();
|
|
|
172
|
+
|
|
153
|
173
|
StringBuilder error = new StringBuilder();
|
|
154
|
174
|
for (int i = 0; i < patientids.stream().count(); i++) {
|
|
155
|
175
|
PatientLabel input=new PatientLabel();
|
|
|
@@ -158,15 +178,14 @@ public class PatientLabelController extends BaseController {
|
|
158
|
178
|
input.setCreateUserName(CurrentUser().getNickName());
|
|
159
|
179
|
input.setCreateUser(CurrentUser().getUserName());
|
|
160
|
180
|
input.setIsDelete(0L);
|
|
|
181
|
+ input.setLabelId(labelid);
|
|
161
|
182
|
input.setPatientId(String_id);
|
|
162
|
183
|
var patient= patientList.stream().filter(x->x.getPatientId().equals(String_id)).collect(Collectors.toList()).stream().findFirst();
|
|
163
|
184
|
input.setLabelName(inputlabel.getLabelName());
|
|
164
|
185
|
input.setPatientName(patient.get().getName() );
|
|
165
|
186
|
input.setPhoneNumber(patient.get().getPhoneNumber());
|
|
166
|
187
|
boolean result = patientlabelService.insert(input);
|
|
167
|
|
- if (!result) {
|
|
168
|
|
- // error.append(patientids.get(i)).append("删除失败;");
|
|
169
|
|
- } else {
|
|
|
188
|
+ if (result) {
|
|
170
|
189
|
//添加标签 存log记录
|
|
171
|
190
|
var ppp= patientList.stream().filter(x->x.getPatientId().equals(String_id)).findFirst().get();
|
|
172
|
191
|
ppp.setUpdateTime(currentDate);
|