提交 | 用户 | age
|
9710f8
|
1 |
package com.hx.phip.controller.treat; |
be3140
|
2 |
|
R |
3 |
import com.alibaba.fastjson.JSONObject; |
|
4 |
import com.github.pagehelper.util.StringUtil; |
|
5 |
import com.hx.common.BaseController; |
f59369
|
6 |
import com.hx.exception.TipsException; |
128220
|
7 |
import com.hx.guide.vo.treatOrder.TreatOrderReqVo; |
5acd7e
|
8 |
import com.hx.mybatis.aes.springbean.VariableAesKey; |
be3140
|
9 |
import com.hx.mybatisTool.SqlSentence; |
eb8351
|
10 |
import com.hx.phiappt.common.DeductionSingleConstants; |
e18c30
|
11 |
import com.hx.phiappt.common.RoleType; |
be3140
|
12 |
import com.hx.phiappt.common.TreatSingleConstants; |
ef962a
|
13 |
import com.hx.phiappt.constants.tool.exception.ExceptionTool; |
ad0ff1
|
14 |
import com.hx.phiappt.dao.mapper.*; |
2cfe2a
|
15 |
import com.hx.phiappt.model.*; |
b33cd3
|
16 |
import com.hx.phiappt.model.guide.VisitOrder; |
be3140
|
17 |
import com.hx.phiappt.model.treat.TreatProject; |
e18c30
|
18 |
import com.hx.phiappt.model.treat.TreatProjectDoctor; |
be3140
|
19 |
import com.hx.phiappt.model.treat.TreatSingle; |
2cfe2a
|
20 |
import com.hx.phiappt.model.treat.TreatSingleSign; |
8fd4fa
|
21 |
import com.hx.phip.config.CustomParameter; |
61ef7d
|
22 |
import com.hx.phip.service.AppointmentService; |
180320
|
23 |
import com.hx.phip.service.EmployeeService; |
be3140
|
24 |
import com.hx.phip.service.UserService; |
de721d
|
25 |
import com.hx.phip.service.treat.TreatSingleService; |
2cfe2a
|
26 |
import com.hx.phip.service.treat.TreatV3Service; |
be3140
|
27 |
import com.hx.phip.tool.SendSMSTool; |
c9c262
|
28 |
import com.hx.phip.util.api.CrmUtil; |
71332a
|
29 |
import com.hx.resultTool.Result; |
be3140
|
30 |
import com.hx.util.DateUtil; |
R |
31 |
import com.hx.util.StringUtils; |
ef962a
|
32 |
import com.hx.util.thread.ExecutorServiceTool; |
8fd4fa
|
33 |
import com.platform.constants.PlatformPattern; |
be3140
|
34 |
import com.platform.exception.PlatTipsException; |
R |
35 |
import com.platform.resultTool.PlatformCode; |
9710f8
|
36 |
import com.platform.resultTool.PlatformResult; |
d81c64
|
37 |
import org.slf4j.Logger; |
R |
38 |
import org.slf4j.LoggerFactory; |
2cfe2a
|
39 |
import org.springframework.web.bind.annotation.RequestBody; |
F |
40 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
41 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
42 |
import org.springframework.web.bind.annotation.RestController; |
be3140
|
43 |
|
R |
44 |
import javax.annotation.Resource; |
5c9d30
|
45 |
import java.util.*; |
be3140
|
46 |
|
R |
47 |
/** |
|
48 |
* 治疗通知单控制器 |
|
49 |
* |
|
50 |
* @USER: zhouxiang |
|
51 |
* @DATE: 2021/12/03 |
|
52 |
*/ |
|
53 |
@RestController |
|
54 |
@RequestMapping("/treat") |
|
55 |
public class TreatController extends BaseController { |
d81c64
|
56 |
|
R |
57 |
private static Logger logger = LoggerFactory.getLogger(TreatController.class); |
be3140
|
58 |
|
R |
59 |
@Resource |
2cfe2a
|
60 |
private TreatV3Service treatV3Service; |
be3140
|
61 |
@Resource |
R |
62 |
private UserService userService; |
61ef7d
|
63 |
@Resource |
R |
64 |
private TreatSingleService treatSingleService; |
|
65 |
@Resource |
|
66 |
private AppointmentService appointmentService; |
e18c30
|
67 |
@Resource |
8fd4fa
|
68 |
private CustomParameter customParameter; |
180320
|
69 |
@Resource |
F |
70 |
private EmployeeService employeeService; |
37a7e2
|
71 |
|
be3140
|
72 |
/** |
R |
73 |
* 创建治疗通知单 |
|
74 |
*/ |
|
75 |
@RequestMapping(value = "/add", method = RequestMethod.POST) |
75d152
|
76 |
public PlatformResult create(@RequestBody TreatOrderReqVo reqVo) { |
128220
|
77 |
|
6df582
|
78 |
logger.info("新增治疗单参数:{}", JSONObject.toJSONString(reqVo) ); |
6ae01a
|
79 |
|
b7f4e6
|
80 |
//治疗通知单对象 |
2d22c6
|
81 |
TreatSingle treatSingle = reqVo.createTreatSingle(); |
2cfe2a
|
82 |
//治疗单签名 |
F |
83 |
List<TreatSingleSign> signList = reqVo.getSignList(); |
6ae01a
|
84 |
|
be3140
|
85 |
//校验参数 |
2cfe2a
|
86 |
checkTreatSingleParam(true, treatSingle, signList); |
128220
|
87 |
|
1c1cdf
|
88 |
//判断是否发送通知MIC分配治疗 |
F |
89 |
Integer isMicNotice = BaseEntity.NO; |
|
90 |
// if(reqVo.getIsMicNotice() != null && reqVo.getIsMicNotice() == BaseEntity.YES){ |
|
91 |
// isMicNotice = BaseEntity.YES; |
|
92 |
// } |
|
93 |
|
128220
|
94 |
//治疗单项目 |
F |
95 |
List<TreatProject> projectList = reqVo.getProjectList(); |
|
96 |
if (projectList == null || projectList.size() == 0) { |
|
97 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "治疗通知单的治疗项目不能为空"); |
|
98 |
} |
6ae01a
|
99 |
//检查项目参数 |
F |
100 |
checkProjectParam(projectList); |
bc99c7
|
101 |
|
2cfe2a
|
102 |
if(StringUtils.isEmpty(reqVo.getRoleId())){ |
F |
103 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "操作人角色标识为空"); |
|
104 |
} |
|
105 |
EmployeeRole employeeRole = employeeService.selectRoleInfoById(reqVo.getRoleId()); |
|
106 |
if(employeeRole == null){ |
|
107 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "查询不到操作人角色信息!"); |
|
108 |
} |
be3140
|
109 |
|
2d22c6
|
110 |
VisitOrder visitOrder = commonService.selectOneByKey(VisitOrderMapper.class, treatSingle.getVisitOrderId()); |
6ae01a
|
111 |
if(visitOrder == null){ |
F |
112 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "查询不到到访订单信息"); |
|
113 |
} |
891640
|
114 |
treatSingle.setUserId(visitOrder.getUserId()); |
1c1cdf
|
115 |
|
F |
116 |
|
|
117 |
treatV3Service.add(treatSingle, projectList, visitOrder, employeeRole, isMicNotice, signList); |
128220
|
118 |
|
ef962a
|
119 |
//开启多线程处理用户科室关系 |
F |
120 |
ExecutorServiceTool fixedThreadPool = new ExecutorServiceTool(1, 1); |
|
121 |
try { |
7e52f3
|
122 |
fixedThreadPool.getThreadPool().execute(() ->{ |
F |
123 |
//处理用户科室关系 |
|
124 |
treatV3Service.doctorRoomHandler(treatSingle.getId()); |
|
125 |
//处理治疗单项目模式数据 |
|
126 |
treatV3Service.handleModeData(projectList); |
|
127 |
}); |
ef962a
|
128 |
}catch (Exception e){ |
7e52f3
|
129 |
logger.error("新增治疗单-开启多线程处理失败:"+ ExceptionTool.getExceptionInfo(e)); |
ef962a
|
130 |
}finally { |
F |
131 |
fixedThreadPool.shutdown(); |
|
132 |
} |
128220
|
133 |
//返回id |
F |
134 |
JSONObject data = new JSONObject(); |
|
135 |
data.put("treatSingleId", treatSingle.getId()); |
|
136 |
|
|
137 |
return PlatformResult.success(data); |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* 修改治疗通知单 |
|
142 |
*/ |
|
143 |
@RequestMapping(value = "/edit", method = RequestMethod.POST) |
|
144 |
public PlatformResult edit(@RequestBody(required = false) TreatOrderReqVo reqVo) { |
|
145 |
|
4a3027
|
146 |
logger.info("修改治疗单参数:{}", JSONObject.toJSONString(reqVo) ); |
F |
147 |
|
128220
|
148 |
//获取-判断治疗通知单信息 |
F |
149 |
if (reqVo == null) { |
|
150 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗单信息为空"); |
|
151 |
} |
|
152 |
|
|
153 |
//治疗通知单对象 |
2d22c6
|
154 |
TreatSingle treatSingle = reqVo.createTreatSingle(); |
2cfe2a
|
155 |
//治疗单签名 |
F |
156 |
List<TreatSingleSign> signList = reqVo.getSignList(); |
128220
|
157 |
//校验参数 |
2cfe2a
|
158 |
checkTreatSingleParam(false, treatSingle, signList); |
F |
159 |
|
2d22c6
|
160 |
|
F |
161 |
List<TreatProject> projectList = reqVo.getProjectList(); |
|
162 |
if (projectList == null || projectList.size() == 0) { |
|
163 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "治疗通知单的治疗项目不能为空"); |
|
164 |
} |
2cfe2a
|
165 |
checkProjectParam(projectList); |
128220
|
166 |
|
F |
167 |
TreatSingle updateTreat = commonService.selectOneByKey(TreatSingleMapper.class,treatSingle.getId()); |
|
168 |
if(updateTreat == null){ |
|
169 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "未找到"); |
|
170 |
} |
|
171 |
|
1c1cdf
|
172 |
// //判断是否发送通知MIC分配治疗(如果治疗单分配医生不为空,则不继续通知MIC) |
F |
173 |
// Integer isMicNotice = BaseEntity.NO; |
|
174 |
// if(reqVo.getIsMicNotice() != null && reqVo.getIsMicNotice() == BaseEntity.YES |
|
175 |
// && StringUtils.noNull(updateTreat.getaDoctorId())){ |
|
176 |
// isMicNotice = BaseEntity.YES; |
|
177 |
// } |
6608fc
|
178 |
|
F |
179 |
if(updateTreat.getStatus() == TreatSingleConstants.STATUS_CANCEL){ |
|
180 |
throwParamException("作废治疗通知单不可修改!"); |
|
181 |
} |
|
182 |
|
2cfe2a
|
183 |
if(StringUtils.isEmpty(reqVo.getRoleId())){ |
F |
184 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "操作人角色标识为空"); |
|
185 |
} |
|
186 |
EmployeeRole employeeRole = employeeService.selectRoleInfoById(reqVo.getRoleId()); |
|
187 |
if(employeeRole == null){ |
|
188 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "查询不到操作人角色信息!"); |
|
189 |
} |
6ae01a
|
190 |
|
6df582
|
191 |
VisitOrder visitOrder = commonService.selectOneByKey(VisitOrderMapper.class, updateTreat.getVisitOrderId()); |
6ae01a
|
192 |
if(visitOrder == null){ |
F |
193 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "查询不到到访订单信息"); |
128220
|
194 |
} |
F |
195 |
|
|
196 |
//修改 |
|
197 |
treatSingle.setTreatSingleNo(updateTreat.getTreatSingleNo()); |
|
198 |
treatSingle.setCommonId(updateTreat.getCommonId()); |
1c1cdf
|
199 |
treatSingle.setaNurseId(updateTreat.getaNurseId()); |
F |
200 |
treatSingle.setaDoctorId(updateTreat.getaDoctorId()); |
2cfe2a
|
201 |
treatV3Service.edit(treatSingle, projectList, visitOrder, employeeRole, updateTreat, signList); |
128220
|
202 |
|
F |
203 |
//当状态是 待确认 发送短信给客户确认 |
|
204 |
if(treatSingle.getStatus()==TreatSingleConstants.STATUS_WAIT_CONFIRM){ |
|
205 |
//修改治疗通知单发送给客户 |
6ae01a
|
206 |
editSendMsg(treatSingle.getId(), visitOrder.getUserId()); |
128220
|
207 |
} |
be3140
|
208 |
|
7e52f3
|
209 |
//开启多线程处理 |
F |
210 |
ExecutorServiceTool fixedThreadPool = new ExecutorServiceTool(1, 1); |
|
211 |
try { |
|
212 |
fixedThreadPool.getThreadPool().execute(() ->{ |
|
213 |
//处理治疗单项目模式数据 |
|
214 |
treatV3Service.handleModeData(projectList); |
|
215 |
}); |
|
216 |
}catch (Exception e){ |
|
217 |
logger.error("编辑治疗单-开启多线程处理失败:"+ ExceptionTool.getExceptionInfo(e)); |
|
218 |
}finally { |
|
219 |
fixedThreadPool.shutdown(); |
|
220 |
} |
|
221 |
|
be3140
|
222 |
//返回id |
128220
|
223 |
JSONObject data = new JSONObject(); |
F |
224 |
data.put("treatSingleId", treatSingle.getId()); |
|
225 |
return PlatformResult.success(data); |
6ae01a
|
226 |
} |
F |
227 |
|
eb8351
|
228 |
/** 作废 */ |
F |
229 |
@RequestMapping(value = "/invalid", method = RequestMethod.POST) |
|
230 |
public PlatformResult invalid(@RequestBody(required = false) TreatOrderReqVo reqVo) { |
|
231 |
|
|
232 |
//获取-判断治疗通知单信息 |
|
233 |
if (reqVo == null) { |
|
234 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗单信息为空"); |
|
235 |
} |
|
236 |
|
|
237 |
if (StringUtils.isEmpty(reqVo.getTreatSingleId())) { |
|
238 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗通知单标识为空"); |
|
239 |
} |
|
240 |
|
|
241 |
if(StringUtils.isEmpty(reqVo.getRoleId())){ |
|
242 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "操作人角色标识为空"); |
|
243 |
} |
|
244 |
|
|
245 |
|
|
246 |
//治疗通知单对象 |
|
247 |
TreatSingle treatSingle = commonService.selectOneByKey(TreatSingleMapper.class, reqVo.getTreatSingleId()); |
|
248 |
if(treatSingle == null){ |
|
249 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "查询不到治疗通知单信息!"); |
|
250 |
} |
|
251 |
|
|
252 |
//查询治疗通知单有划扣过(已执行),则不可作废 |
|
253 |
SqlSentence sqlSentence = new SqlSentence(); |
|
254 |
Map<String, Object> values = new HashMap<>(); |
|
255 |
sqlSentence.setM(values); |
|
256 |
values.put("treatSingleId", reqVo.getTreatSingleId()); |
|
257 |
values.put("commonId", treatSingle.getCommonId()); |
|
258 |
values.put("status", DeductionSingleConstants.STATUS_DONE_EXECUTE); |
|
259 |
sqlSentence.setSqlSentence(" isDel = 0 and status = #{m.status} and commonId = #{m.commonId} and treatSingleId = #{m.treatSingleId} "); |
|
260 |
int count = commonService.selectCount(com.hx.phiappt.dao.mapper.DeductionSingleMapper.class, sqlSentence); |
|
261 |
if(count > 0){ |
|
262 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗通知单有划扣记录,不可作废!如想作废请先作废关联划扣记录"); |
|
263 |
} |
|
264 |
|
|
265 |
EmployeeRole employeeRole = employeeService.selectRoleInfoById(reqVo.getRoleId()); |
|
266 |
if(employeeRole == null){ |
|
267 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "查询不到操作人角色信息!"); |
|
268 |
} |
|
269 |
|
|
270 |
VisitOrder visitOrder = commonService.selectOneByKey(VisitOrderMapper.class, treatSingle.getVisitOrderId()); |
|
271 |
if(visitOrder == null){ |
|
272 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "查询不到到访订单信息"); |
|
273 |
} |
|
274 |
|
|
275 |
treatV3Service.invalidTreat(treatSingle, visitOrder, employeeRole); |
|
276 |
|
|
277 |
return PlatformResult.success(); |
|
278 |
} |
71332a
|
279 |
|
F |
280 |
/** 更新治疗单签名 */ |
|
281 |
@RequestMapping(value ="/updateSign", method = RequestMethod.POST) |
|
282 |
public Result updateSign(@RequestBody(required = false) TreatOrderReqVo reqVo){ |
|
283 |
if(reqVo == null){ |
|
284 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "请求对象为空!"); |
|
285 |
} |
|
286 |
|
|
287 |
if(StringUtils.isEmpty(reqVo.getRoleId())){ |
|
288 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "操作人标识不能为空!"); |
|
289 |
} |
|
290 |
|
|
291 |
if(StringUtils.isEmpty(reqVo.getTreatSingleId())){ |
|
292 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "操作人标识不能为空!"); |
|
293 |
} |
|
294 |
|
|
295 |
if(reqVo.getSignList() == null || reqVo.getSignList().size() < 1){ |
|
296 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "签名信息不能为空!"); |
|
297 |
} |
|
298 |
|
|
299 |
|
|
300 |
EmployeeRole employeeRole = employeeService.selectRoleInfoById(reqVo.getRoleId()); |
|
301 |
if(employeeRole == null){ |
|
302 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "查询不到操作人角色信息!"); |
|
303 |
} |
|
304 |
|
|
305 |
TreatSingle treatSingle = treatSingleService.selectOneByKey(reqVo.getTreatSingleId()); |
|
306 |
if(treatSingle == null){ |
|
307 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "查询不到治疗通知单信息!"); |
|
308 |
} |
1930e1
|
309 |
//先获取旧的,因为统一校验方法会覆盖,校验完后再重新set值 |
F |
310 |
Integer isUserSign = treatSingle.getIsUserSign(); |
37022a
|
311 |
checkSignParam(reqVo.getSignList(), treatSingle); |
1930e1
|
312 |
treatSingle.setIsUserSign(isUserSign); |
71332a
|
313 |
|
F |
314 |
treatV3Service.updateSign(treatSingle, reqVo.getSignList(), employeeRole); |
|
315 |
|
|
316 |
return Result.success(); |
|
317 |
} |
be3140
|
318 |
|
R |
319 |
/** |
|
320 |
* 客户确认治疗通知单 |
|
321 |
*/ |
9710f8
|
322 |
@RequestMapping(value = "/confirmTreatNotice", method = RequestMethod.POST) |
R |
323 |
public PlatformResult confirmTreatNotice(@RequestBody String param) { |
|
324 |
if (StringUtils.isEmpty(param)) { |
b7f4e6
|
325 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "治疗单参数为空"); |
be3140
|
326 |
} |
c83f0f
|
327 |
|
9710f8
|
328 |
JSONObject jsonObject = JSONObject.parseObject(param); |
R |
329 |
if (!jsonObject.containsKey("treatSingleId")) { |
|
330 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗单id为空"); |
|
331 |
} |
c83f0f
|
332 |
|
61ef7d
|
333 |
TreatSingle treatSingle = treatSingleService.selectOneByKey(jsonObject.getString("treatSingleId")); |
9710f8
|
334 |
if (treatSingle == null) { |
c83f0f
|
335 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "找不到治疗通知单信息"); |
F |
336 |
} |
|
337 |
|
9710f8
|
338 |
if (treatSingle.getStatus() == TreatSingleConstants.STATUS_CONFIRM) { |
c83f0f
|
339 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗通知单已确认"); |
F |
340 |
} |
|
341 |
|
ed5590
|
342 |
Appointment appointment = appointmentService.selectOneByKeyBlob(treatSingle.getCommonId()); |
R |
343 |
if(appointment == null){ |
|
344 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "找不到预约单信息"); |
|
345 |
} |
|
346 |
|
|
347 |
|
|
348 |
treatSingleService.updateTreatStatus(treatSingle,appointment,commonService); |
61ef7d
|
349 |
|
9710f8
|
350 |
return PlatformResult.success(); |
be3140
|
351 |
} |
R |
352 |
|
|
353 |
/** |
|
354 |
* 查询治疗通知单详情信息 |
|
355 |
*/ |
|
356 |
@RequestMapping(value = "/info", method = RequestMethod.POST) |
9710f8
|
357 |
public PlatformResult getTreatList(@RequestBody String param) { |
be3140
|
358 |
//判断参数 |
9710f8
|
359 |
if (StringUtil.isEmpty(param)) { |
R |
360 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗通知单id不能为空"); |
|
361 |
} |
|
362 |
|
|
363 |
JSONObject jsonObject = JSONObject.parseObject(param); |
|
364 |
if (!jsonObject.containsKey("treatSingleId")) { |
b7f4e6
|
365 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗通知单id不能为空"); |
be3140
|
366 |
} |
9710f8
|
367 |
|
be3140
|
368 |
//查询治疗通知单 |
61ef7d
|
369 |
TreatSingle treatSingle = treatSingleService.selectOneByKey(jsonObject.getString("treatSingleId")); |
be3140
|
370 |
if (treatSingle == null) { |
9710f8
|
371 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗通知单id不能为空"); |
be3140
|
372 |
} |
R |
373 |
//查询预约信息 |
61ef7d
|
374 |
Appointment appointment = appointmentService.selectOneByKey( treatSingle.getCommonId()); |
be3140
|
375 |
if (appointment == null) { |
9710f8
|
376 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "找不到预约信息"); |
be3140
|
377 |
} |
R |
378 |
|
|
379 |
SqlSentence sqlSentence = new SqlSentence(); |
|
380 |
Map<String, Object> map = new HashMap<>(); |
|
381 |
sqlSentence.setM(map); |
|
382 |
|
|
383 |
//查询项目信息 |
|
384 |
map.put("singleId", treatSingle.getId()); |
d466ed
|
385 |
sqlSentence.setSqlSentence("SELECT p.positionData, p.projectNo as projectId,p.hisId as projectNo, p.projectName, p.num FROM treat_project p LEFT JOIN treat_single s ON p.treatSingleId = s.id where p.treatSingleId = #{m.singleId} and s.isDel=0 and p.isDel=0"); |
be3140
|
386 |
List<Map<String, Object>> projectList = commonService.selectListMap(TreatProjectMapper.class, sqlSentence); |
R |
387 |
|
|
388 |
//人员信息 |
|
389 |
map.put("userId", appointment.getUserId()); |
5acd7e
|
390 |
map.put("key", VariableAesKey.AES_KEY); |
Z |
391 |
sqlSentence.setSqlSentence("select insert(CONVERT(AES_DECRYPT(UNHEX(tel), #{m.key}) , CHAR), 4, 4, '****') as tel,id,name,CIQ from user where id=#{m.userId} and isDel=0 "); |
be3140
|
392 |
User user = commonService.selectOne(UserMapper.class, sqlSentence); |
R |
393 |
if (user == null) { |
b7f4e6
|
394 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "用户信息为空"); |
be3140
|
395 |
} |
e18c30
|
396 |
//医生信息 |
Z |
397 |
sqlSentence.setSqlSentence("select * from treat_project_doctor where isDel=0 and treatSingleId=#{m.singleId}"); |
|
398 |
List<TreatProjectDoctor> projectDoctors = commonService.selectList(TreatProjectDoctorMapper.class, sqlSentence); |
|
399 |
List<Map<String, Object>> maps=new ArrayList<>(); |
|
400 |
if(projectDoctors !=null && projectDoctors.size()>0){ |
3594e1
|
401 |
for(TreatProjectDoctor vo:projectDoctors){ |
Z |
402 |
Map<String,Object> employeeMap=new HashMap<>(); |
|
403 |
Employee employee=commonService.selectOneByKey(EmployeeMapper.class, vo.getCommonId()); |
|
404 |
employeeMap.put("projectId",vo.getTreatProjectId()); |
|
405 |
employeeMap.put("projectHisId",vo.getTreatProjectHisId()); |
|
406 |
employeeMap.put("employeeName",employee.getCnName()); |
|
407 |
employeeMap.put("employeeId",employee.getId()); |
|
408 |
maps.add(employeeMap); |
|
409 |
} |
e18c30
|
410 |
} |
be3140
|
411 |
|
R |
412 |
map.clear(); |
|
413 |
map.put("createTime", DateUtil.formatDate(treatSingle.getCreateTime(), "yyy.MM.dd HH:mm")); |
|
414 |
map.put("name", user.getName()); |
|
415 |
map.put("ciq", user.getCIQ()); |
|
416 |
map.put("tel", user.getTel()); |
|
417 |
map.put("shopName", treatSingle.getShopName()); |
|
418 |
map.put("employeeName", treatSingle.getOperatorName()); |
|
419 |
map.put("projectList", projectList); |
|
420 |
map.put("remarkInfo", treatSingle.getRemarkInfo()); |
4ea264
|
421 |
map.put("status",treatSingle.getStatus()); |
e18c30
|
422 |
map.put("employeeList",maps); |
71c38a
|
423 |
map.put("employeeType",appointment.getIsLifeBeauty() ==null||appointment.getIsLifeBeauty()==0? RoleType.UNIQUE_STR_DOCTOR:RoleType.UNIQUE_STR_NURSE); |
4ea264
|
424 |
|
9710f8
|
425 |
return PlatformResult.success(map); |
be3140
|
426 |
} |
R |
427 |
|
|
428 |
/** |
|
429 |
* 重新发送短信 |
9710f8
|
430 |
* |
R |
431 |
* @param param |
be3140
|
432 |
* @return |
R |
433 |
*/ |
|
434 |
@RequestMapping("/againSendMsg") |
9710f8
|
435 |
public PlatformResult sendMsg(@RequestBody String param) { |
R |
436 |
//校验参数 |
be3140
|
437 |
if (StringUtils.isEmpty(param)) { |
R |
438 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传治疗通知单参数"); |
|
439 |
} |
9710f8
|
440 |
//转成对象 |
be3140
|
441 |
JSONObject object = JSONObject.parseObject(param); |
9710f8
|
442 |
//判断参数 |
R |
443 |
if (!object.containsKey("treatSingleId")) { |
|
444 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传治疗通知单参数"); |
|
445 |
} |
|
446 |
//查询治疗通知单 |
b7f4e6
|
447 |
TreatSingle treatSingle = commonService.selectOneByKey(TreatSingleMapper.class, object.getString("treatSingleId")); |
9710f8
|
448 |
if (treatSingle == null) { |
R |
449 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "找不到治疗通知单信息"); |
|
450 |
} |
|
451 |
//判断状态 短信是否是已确认 未确认发送短信 |
|
452 |
if (treatSingle.getStatus() == TreatSingleConstants.STATUS_CONFIRM) { |
|
453 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗通知单已确认"); |
|
454 |
} |
be3140
|
455 |
|
ed5590
|
456 |
//查询预约信息 |
b33cd3
|
457 |
Appointment appointment = commonService.selectOneByKey(AppointmentMapper.class, treatSingle.getCommonId()); |
ed5590
|
458 |
if (appointment == null) { |
R |
459 |
throw new TipsException("找不到预约信息"); |
|
460 |
} |
|
461 |
|
|
462 |
//用户信息 |
b33cd3
|
463 |
User userInfo = commonService.selectOneByKey(UserMapper.class, appointment.getUserId()); |
ed5590
|
464 |
if (userInfo == null) { |
R |
465 |
throw new TipsException("找不到用户信息!"); |
|
466 |
} |
|
467 |
|
be3140
|
468 |
SqlSentence sqlSentence = new SqlSentence(); |
R |
469 |
Map<String, Object> values = new HashMap<>(); |
|
470 |
sqlSentence.setM(values); |
|
471 |
//通过预约id查询到预约信息获取用户手机号 |
|
472 |
values.put("commonId", object.getString("appId")); |
0d64a4
|
473 |
sqlSentence.setSqlSentence("select u.tel from appointment a left join user u on u.id=a.userId where a.id =#{m.commonId} and u.isDel=0 and a.isDel=0 "); |
be3140
|
474 |
Map<String, Object> map = userService.selectOneMap(sqlSentence); |
c9c262
|
475 |
if(PlatformPattern.PROD.equals(customParameter.getPlatformPattern())){ |
Z |
476 |
map.put("treatSingleId",treatSingle.getId()); |
|
477 |
CrmUtil.sendCrmSMS(map,commonService,0); |
|
478 |
}else{ |
|
479 |
net.sf.json.JSONObject jsonObject = new net.sf.json.JSONObject(); |
|
480 |
//发送短信 |
|
481 |
jsonObject = SendSMSTool.msgSend("测试服假链接"+"https://wxaurl.cn/66666666", map.get("tel").toString(), "", 1); |
d81c64
|
482 |
|
37cf38
|
483 |
// logger.info("发送短信返回:"+jsonObject.toString()); |
d81c64
|
484 |
|
c9c262
|
485 |
if (jsonObject.getInt("code") != 0) { |
Z |
486 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "发送短信失败"); |
|
487 |
} |
be3140
|
488 |
} |
ed5590
|
489 |
|
R |
490 |
// VLatelyLog vLatelyLog = new VLatelyLog(TreatSingleConstants.STATUS_CONFIRM, "客户自己确认治疗通知单", "治疗通知单,客户已确认自己的治疗通知单", userInfo.getCIQ() + userInfo.getName(), null, |
|
491 |
// null, null, null, userInfo.getId()); |
|
492 |
// |
|
493 |
// commonService.insert(com.hx.guide.dao.mapper.VLatelyLogMapper.class,vLatelyLog); |
|
494 |
|
9710f8
|
495 |
|
R |
496 |
return PlatformResult.success(); |
|
497 |
|
be3140
|
498 |
} |
a1a890
|
499 |
|
66cafd
|
500 |
|
2cfe2a
|
501 |
//////////////////////////////////////////////////////////////////////////////////////////////// |
180320
|
502 |
|
4667b8
|
503 |
public void editSendMsg(String treatSingleId,String userId) { |
85a86c
|
504 |
|
Z |
505 |
//查询治疗通知单 |
|
506 |
TreatSingle treatSingle = commonService.selectOneByKey(TreatSingleMapper.class, treatSingleId); |
|
507 |
if (treatSingle == null) { |
|
508 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "找不到治疗通知单信息"); |
|
509 |
} |
fcdf38
|
510 |
// //判断状态 短信是否是已确认 未确认发送短信 |
Z |
511 |
// if (treatSingle.getStatus() == TreatSingleConstants.STATUS_CONFIRM) { |
|
512 |
// throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_TYPE, "治疗通知单已确认"); |
|
513 |
// } |
85a86c
|
514 |
|
ed5590
|
515 |
|
R |
516 |
//查询预约信息 |
0240a3
|
517 |
Appointment appointment = commonService.selectOneByKey(AppointmentMapper.class, treatSingle.getCommonId()); |
ed5590
|
518 |
if (appointment == null) { |
R |
519 |
throw new TipsException("找不到预约信息"); |
|
520 |
} |
|
521 |
|
|
522 |
//用户信息 |
0240a3
|
523 |
User userInfo = commonService.selectOneByKey(UserMapper.class, appointment.getUserId()); |
ed5590
|
524 |
if (userInfo == null) { |
R |
525 |
throw new TipsException("找不到用户信息!"); |
|
526 |
} |
|
527 |
|
|
528 |
|
85a86c
|
529 |
SqlSentence sqlSentence = new SqlSentence(); |
Z |
530 |
Map<String, Object> values = new HashMap<>(); |
|
531 |
sqlSentence.setM(values); |
|
532 |
//通过预约id查询到预约信息获取用户手机号 |
|
533 |
values.put("commonId", userId); |
fcdf38
|
534 |
sqlSentence.setSqlSentence("SELECT tel FROM `user` WHERE id = #{m.commonId} AND isDel = 0"); |
85a86c
|
535 |
Map<String, Object> map = userService.selectOneMap(sqlSentence); |
Z |
536 |
|
c9c262
|
537 |
if(PlatformPattern.PROD.equals(customParameter.getPlatformPattern())){ |
Z |
538 |
map.put("treatSingleId",treatSingle.getId()); |
|
539 |
CrmUtil.sendCrmSMS(map,commonService,1); |
|
540 |
}else{ |
|
541 |
net.sf.json.JSONObject jsonObject = new net.sf.json.JSONObject(); |
|
542 |
//发送短信 |
|
543 |
jsonObject = SendSMSTool.msgSend("测试服假链接"+"https://wxaurl.cn/66666666", map.get("tel").toString(), "", 1); |
85a86c
|
544 |
|
c9c262
|
545 |
// logger.info("发送短信返回:"+jsonObject.toString()); |
85a86c
|
546 |
|
c9c262
|
547 |
if (jsonObject.getInt("code") != 0) { |
Z |
548 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "发送短信失败"); |
|
549 |
} |
85a86c
|
550 |
} |
ed5590
|
551 |
|
R |
552 |
|
|
553 |
// VLatelyLog vLatelyLog = new VLatelyLog(TreatSingleConstants.STATUS_CONFIRM, "修改治疗单时客户需确认治疗单", "修改治疗通知单,客户已确认自己的治疗通知单", userInfo.getCIQ() + userInfo.getName(), null, |
|
554 |
// null, null, null, userInfo.getId()); |
|
555 |
// |
|
556 |
// commonService.insert(com.hx.guide.dao.mapper.VLatelyLogMapper.class,vLatelyLog); |
|
557 |
|
85a86c
|
558 |
} |
Z |
559 |
|
a1a890
|
560 |
|
128220
|
561 |
/** 治疗通知单参数校验 */ |
2cfe2a
|
562 |
private void checkTreatSingleParam(boolean isAdd, TreatSingle treatSingle, List<TreatSingleSign> signList) { |
F |
563 |
|
|
564 |
//新增才校验的参数 |
|
565 |
if(isAdd){ |
|
566 |
if (StringUtils.isEmpty(treatSingle.getCommonId())) { |
|
567 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "预约id为空"); |
|
568 |
} |
|
569 |
|
|
570 |
if (StringUtils.isEmpty(treatSingle.getVisitOrderId())) { |
|
571 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "到访订单标识为空"); |
|
572 |
} |
|
573 |
} |
be3140
|
574 |
|
R |
575 |
if (StringUtils.isEmpty(treatSingle.getType())) { |
|
576 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "治疗通知单类型为空"); |
|
577 |
} |
|
578 |
|
|
579 |
if (treatSingle.getStatus() == null) { |
|
580 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "状态为空"); |
|
581 |
} |
bc99c7
|
582 |
if (StringUtils.isEmpty(treatSingle.getShopId())) { |
R |
583 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "所属门店标识为空"); |
|
584 |
} |
a1a890
|
585 |
|
bc99c7
|
586 |
if (StringUtils.isEmpty(treatSingle.getOperatorId())) { |
R |
587 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "下单操作人标识为空"); |
|
588 |
} |
|
589 |
|
|
590 |
if (StringUtils.isEmpty(treatSingle.getDeveloperShopId())) { |
|
591 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "开单人门店标识为空"); |
|
592 |
} |
|
593 |
|
|
594 |
if (StringUtils.isEmpty(treatSingle.getDeveloperId())) { |
|
595 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "开单人标识为空"); |
|
596 |
} |
128220
|
597 |
|
4da8cc
|
598 |
if (treatSingle.getOrderClassify() == null) { |
F |
599 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "订单分类不能为空!"); |
|
600 |
} |
2cfe2a
|
601 |
|
F |
602 |
//校验签名参数---------------------------------------------------------------------------------- |
|
603 |
if(signList != null && signList.size() > 0){ |
37022a
|
604 |
checkSignParam(signList, treatSingle); |
2cfe2a
|
605 |
} |
F |
606 |
|
|
607 |
//---------------------------------------------------------------------------------- |
be3140
|
608 |
} |
R |
609 |
|
71332a
|
610 |
/** 检测校验治疗单签名参数 */ |
37022a
|
611 |
private void checkSignParam(List<TreatSingleSign> signList, TreatSingle treatSingle){ |
F |
612 |
treatSingle.setIsUserSign(BaseEntity.NO); |
71332a
|
613 |
for(TreatSingleSign sign : signList){ |
399961
|
614 |
|
71332a
|
615 |
if(StringUtils.isEmpty(sign.getSignPerType())){ |
F |
616 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"签名人类型不能为空!"); |
|
617 |
} |
|
618 |
if(StringUtils.isEmpty(sign.getSignPerName())){ |
|
619 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"签名人名称不能为空!"); |
|
620 |
} |
|
621 |
//判断类型,更改对应值 |
|
622 |
if(TreatSingleSign.SIGN_PER_TYPE_USER.equals(sign.getSignPerType())){ |
|
623 |
sign.setSortNo(1); |
37022a
|
624 |
treatSingle.setIsUserSign(BaseEntity.YES); |
71332a
|
625 |
}else if(TreatSingleSign.SIGN_PER_TYPE_NURSE1.equals(sign.getSignPerType())){ |
F |
626 |
sign.setSortNo(2); |
399961
|
627 |
continue; //跳过不判断图片,可为空 |
71332a
|
628 |
}else if(TreatSingleSign.SIGN_PER_TYPE_NURSE2.equals(sign.getSignPerType())){ |
F |
629 |
sign.setSortNo(3); |
399961
|
630 |
continue; //跳过不判断图片,可为空 |
71332a
|
631 |
}else if(TreatSingleSign.SIGN_PER_TYPE_DOCTOR.equals(sign.getSignPerType())){ |
F |
632 |
sign.setSortNo(4); |
|
633 |
} |
399961
|
634 |
|
F |
635 |
if(StringUtils.isEmpty(sign.getSignImg())){ |
|
636 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"签名图片不能为空!"); |
|
637 |
} |
|
638 |
|
71332a
|
639 |
} |
F |
640 |
} |
|
641 |
|
128220
|
642 |
/** 治疗项目参数校验 */ |
2cfe2a
|
643 |
private void checkProjectParam(List<TreatProject> treatProjectList) { |
be3140
|
644 |
|
5c9d30
|
645 |
Set<String> idSet = new HashSet<>(); |
F |
646 |
TreatProject oldData; |
2cfe2a
|
647 |
for(TreatProject treatProject : treatProjectList){ |
a1a890
|
648 |
if (StringUtils.isEmpty(treatProject.getProjectNo())) { |
R |
649 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "项目编号不能为空"); |
|
650 |
} |
|
651 |
|
|
652 |
if (StringUtils.isEmpty(treatProject.getProjectName())) { |
|
653 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "项目名称不能为空"); |
|
654 |
} |
|
655 |
|
|
656 |
if (treatProject.getPrice() == null) { |
|
657 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "价格不能为空"); |
|
658 |
} |
|
659 |
|
|
660 |
if (treatProject.getNum() == null) { |
|
661 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "数量不能为空"); |
|
662 |
} |
|
663 |
|
|
664 |
if (treatProject.getUseDuration() == null) { |
|
665 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "治疗时长不能为空"); |
|
666 |
} |
|
667 |
|
|
668 |
if (StringUtils.isEmpty(treatProject.getProjectId())) { |
|
669 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "项目标识不能为空"); |
|
670 |
} |
|
671 |
|
bb9a8c
|
672 |
if (StringUtils.isEmpty(treatProject.getGoodsId())) { |
F |
673 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "公用项目标识不能为空"); |
|
674 |
} |
|
675 |
|
5c9d30
|
676 |
if(StringUtils.noNull(treatProject.getUserProjectItemId()) && idSet.contains(treatProject.getUserProjectItemId())){ |
F |
677 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "治疗单选择用户项目重复!"); |
|
678 |
} |
|
679 |
idSet.add(treatProject.getUserProjectItemId()); |
|
680 |
|
|
681 |
if(StringUtils.noNull(treatProject.getId())){ |
|
682 |
oldData = commonService.selectOneByKey(TreatProjectMapper.class, treatProject.getId()); |
|
683 |
if(oldData == null){ |
|
684 |
throw new TipsException("查询不到原治疗单项目信息!"); |
|
685 |
} |
|
686 |
|
a36888
|
687 |
if(StringUtils.noNull(oldData.getUserProjectItemId()) && !oldData.getUserProjectItemId().equals(treatProject.getUserProjectItemId())){ |
5c9d30
|
688 |
throw new TipsException("已购买治疗单项目不可替换!"); |
F |
689 |
} |
|
690 |
} |
|
691 |
|
a65992
|
692 |
// if (StringUtils.isEmpty(treatProject.getUserProjectItemId())) { |
F |
693 |
// throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "用户项目标识不能为空"); |
|
694 |
// } |
2cfe2a
|
695 |
} |
a1a890
|
696 |
} |
R |
697 |
|
|
698 |
|
2cfe2a
|
699 |
|
F |
700 |
|
be3140
|
701 |
} |