提交 | 用户 | age
|
2cfe2a
|
1 |
package com.hx.phip.service.treat.impl; |
F |
2 |
|
ef962a
|
3 |
import com.alibaba.fastjson.JSON; |
7e52f3
|
4 |
import com.alibaba.fastjson.JSONArray; |
F |
5 |
import com.alibaba.fastjson.JSONObject; |
2cfe2a
|
6 |
import com.hx.common.dao.CommonDao; |
F |
7 |
import com.hx.common.service.CommonService; |
|
8 |
import com.hx.exception.TipsException; |
|
9 |
import com.hx.guide.config.BaseConfig; |
|
10 |
import com.hx.guide.service.tools.TreatSingleLogTool; |
|
11 |
import com.hx.guide.service.tools.VGuideLogTool; |
|
12 |
import com.hx.guide.service.tools.VLatelyLogTool; |
|
13 |
import com.hx.guide.util.CreateNo; |
|
14 |
import com.hx.guide.util.TreatNoticeUtil; |
|
15 |
import com.hx.mybatisTool.SqlSentence; |
|
16 |
import com.hx.phiappt.common.RoleType; |
|
17 |
import com.hx.phiappt.common.TreatSingleConstants; |
b33cd3
|
18 |
import com.hx.phiappt.constants.VisitOrderCommon; |
C |
19 |
import com.hx.phiappt.constants.VisitOrderLogConstants; |
d6e1c5
|
20 |
import com.hx.phiappt.constants.tool.employee.EmployeeTool; |
b33cd3
|
21 |
import com.hx.phiappt.dao.mapper.*; |
2cfe2a
|
22 |
import com.hx.phiappt.model.*; |
b33cd3
|
23 |
import com.hx.phiappt.model.guide.VisitOrder; |
2cfe2a
|
24 |
import com.hx.phiappt.model.treat.*; |
7e52f3
|
25 |
import com.hx.phiappt.vo.treat.TreatProjectModeDataVo; |
d6e1c5
|
26 |
import com.hx.phip.common.wx.corp.WeiXinCorpMpUtil; |
F |
27 |
import com.hx.phip.common.wx.corp.WeiXinMpUtil; |
2cfe2a
|
28 |
import com.hx.phip.config.CustomParameter; |
F |
29 |
import com.hx.phip.config.GlobalExceptionHandler; |
|
30 |
import com.hx.phip.service.treat.TreatV3Service; |
|
31 |
import com.hx.phip.util.api.TreatUtil; |
|
32 |
import com.hx.util.StringUtils; |
|
33 |
import com.platform.constants.PlatformPattern; |
|
34 |
import com.platform.exception.PlatTipsException; |
|
35 |
import com.platform.resultTool.PlatformCode; |
|
36 |
import org.slf4j.Logger; |
|
37 |
import org.slf4j.LoggerFactory; |
|
38 |
import org.springframework.stereotype.Service; |
|
39 |
import org.springframework.transaction.annotation.Transactional; |
|
40 |
|
|
41 |
import javax.annotation.Resource; |
|
42 |
import java.util.*; |
|
43 |
import java.util.function.Function; |
|
44 |
import java.util.stream.Collectors; |
|
45 |
|
|
46 |
@Transactional |
|
47 |
@Service |
|
48 |
public class TreatV3ServiceImpl implements TreatV3Service { |
|
49 |
|
|
50 |
private static Logger logger = LoggerFactory.getLogger(TreatV3ServiceImpl.class); |
|
51 |
|
|
52 |
|
|
53 |
@Resource |
|
54 |
private ShopMapper shopMapper; |
|
55 |
@Resource |
|
56 |
private EmployeeMapper employeeMapper; |
|
57 |
@Resource |
|
58 |
private TreatSingleMapper treatSingleMapper; |
|
59 |
@Resource |
|
60 |
private TreatProjectMapper treatProjectMapper; |
|
61 |
@Resource |
|
62 |
private UserMapper userMapper; |
|
63 |
@Resource |
|
64 |
private CommonService commonService; |
|
65 |
@Resource |
|
66 |
private CustomParameter customParameter; |
|
67 |
@Resource |
|
68 |
private VisitOrderMapper visitOrderMapper; |
|
69 |
@Resource |
|
70 |
private CommonDao commonDao; |
|
71 |
@Resource |
|
72 |
private TreatProjectDoctorMapper treatProjectDoctorMapper; |
|
73 |
@Resource |
|
74 |
private TreatBodyPartMapper treatBodyPartMapper; |
ef962a
|
75 |
@Resource |
F |
76 |
private UserFamiliesRoomMapper userFamiliesRoomMapper; |
|
77 |
@Resource |
|
78 |
private FamiliesRoomMapper familiesRoomMapper; |
8d7468
|
79 |
@Resource |
F |
80 |
private UserBeChangeLogMapper userBeChangeLogMapper; |
502947
|
81 |
@Resource |
F |
82 |
private TreatSingleSignMapper treatSingleSignMapper; |
7e52f3
|
83 |
@Resource |
F |
84 |
private SystemParameterMapper systemParameterMapper; |
d6e1c5
|
85 |
|
2cfe2a
|
86 |
|
F |
87 |
|
|
88 |
/** 新增治疗通知单 */ |
|
89 |
@Override |
|
90 |
public void add(TreatSingle treatSingle, List<TreatProject> projectList, VisitOrder visitOrder |
1c1cdf
|
91 |
, EmployeeRole employeeRole, Integer isMicNotice, List<TreatSingleSign> signList) { |
2cfe2a
|
92 |
|
F |
93 |
SqlSentence sqlSentence = new SqlSentence(); |
|
94 |
Map<String, Object> values = new HashMap<>(); |
|
95 |
sqlSentence.setM(values); |
|
96 |
|
|
97 |
//判断查询操作员工信息 |
|
98 |
Employee employee = employeeMapper.selectOneByKey(treatSingle.getOperatorId()); |
|
99 |
if (employee == null) { |
|
100 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到操作人的信息[01]:" + treatSingle.getOperatorId()); |
|
101 |
} |
|
102 |
treatSingle.setOperatorName(employee.getCnName()); |
|
103 |
//创建编号 |
|
104 |
treatSingle.setTreatSingleNo(CreateNo.createGivenNo("ZLD", employee.getCnName())); |
|
105 |
|
|
106 |
|
|
107 |
//判断查询操作员工门店信息 |
|
108 |
Shop shop = shopMapper.selectOneByKey(treatSingle.getShopId()); |
|
109 |
if (shop == null) { |
|
110 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到操作人门店信息" + treatSingle.getShopId()); |
|
111 |
} |
|
112 |
treatSingle.setShopName(shop.getName()); |
|
113 |
|
|
114 |
//判断查询开单人 |
|
115 |
employee = employeeMapper.selectOneByKey(treatSingle.getDeveloperId()); |
|
116 |
if (employee == null) { |
|
117 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到开单人的信息" + treatSingle.getDeveloperId()); |
|
118 |
} |
|
119 |
treatSingle.setDeveloperName(employee.getCnName()); |
|
120 |
|
|
121 |
//判断查询开单人门店信息 |
|
122 |
shop = shopMapper.selectOneByKey(treatSingle.getDeveloperShopId()); |
|
123 |
if (shop == null) { |
|
124 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到开单人门店信息" + treatSingle.getDeveloperShopId()); |
|
125 |
} |
|
126 |
treatSingle.setDeveloperShopName(shop.getName()); |
|
127 |
|
|
128 |
//创建治疗通知单 |
|
129 |
if (treatSingleMapper.insert(treatSingle) != 1) { |
|
130 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "新增治疗通知单失败!"); |
|
131 |
} |
|
132 |
|
|
133 |
//更改到访订单中的的是否开治疗单状态------------------------------------------------------- |
|
134 |
values.clear(); |
|
135 |
values.put("id", visitOrder.getId()); |
|
136 |
sqlSentence.setSqlSentence(" isTreatOrder = isTreatOrder + 1 where id = #{m.id} "); |
|
137 |
//如果到访单为待沟通,则创建治疗通知单后修改状态为:分配治疗 |
|
138 |
if(visitOrder.getStatus() == VisitOrderCommon.WAIT_GT){ |
|
139 |
values.put("status", VisitOrderCommon.STATUS_DISTRIBUTIVE_TREAT); |
|
140 |
sqlSentence.setSqlSentence(" status = #{m.status}, isTreatOrder = isTreatOrder + 1 where id = #{m.id} "); |
|
141 |
} |
|
142 |
if (visitOrderMapper.updateWhere(sqlSentence) != 1) { |
|
143 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "新增治疗通知单:更新到访订单状态失败!"); |
|
144 |
} |
|
145 |
|
|
146 |
//创建治疗项目----------------------------------------------------------------------------- |
d6e1c5
|
147 |
StringBuffer projectNameSb = new StringBuffer(); |
F |
148 |
String doctorName = null; |
2cfe2a
|
149 |
for (TreatProject project : projectList) { |
F |
150 |
project.setPositionData(""); |
|
151 |
project.setTreatSingleNo(treatSingle.getTreatSingleNo()); |
|
152 |
project.setTreatSingleId(treatSingle.getId()); |
|
153 |
if (treatProjectMapper.insert(project) != 1) { |
|
154 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "新增治疗项目失败!"); |
|
155 |
} |
|
156 |
//新增关联治疗通知单项目的医生 |
d6e1c5
|
157 |
doctorName = addTreatProjectDoctor(project, doctorName); |
2cfe2a
|
158 |
//新增处理部位信息 |
F |
159 |
handleBodyPart(project, false); |
|
160 |
//处理项目适应症 |
|
161 |
handleTreatProjectIndication(project, true); |
d6e1c5
|
162 |
//拼接项目名 |
F |
163 |
projectNameSb.append(projectNameSb.length() > 0 ? "+" : "").append(project.getProjectName()); |
2cfe2a
|
164 |
} |
F |
165 |
|
|
166 |
//处理治疗单签名------------------------------------------------------------------------- |
502947
|
167 |
handleSignData(signList, treatSingle.getId(), false, employeeRole); |
2cfe2a
|
168 |
|
F |
169 |
//新增治疗单日志 |
|
170 |
StringBuffer logInfo = TreatSingleLogTool.addLogInfo(treatSingle, projectList); |
|
171 |
TreatSingleLogTool.addLog(commonService, TreatSingleConstants.LOG_TYPE_CREATE, treatSingle, employeeRole, logInfo.toString()); |
|
172 |
|
1c1cdf
|
173 |
// //所有状态下都发送治疗通知单给MIC |
F |
174 |
// //发送企业微信通知MIC进行分配治疗(正式环境才发) |
|
175 |
// if (isMicNotice == BaseEntity.YES && PlatformPattern.PROD.equals(customParameter.getPlatformPattern())) { |
|
176 |
// try{ |
|
177 |
// String mpToken = WeiXinMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId()); |
|
178 |
// String corpMpToken = WeiXinCorpMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId()); |
|
179 |
// if(StringUtils.isEmpty(mpToken)){ |
|
180 |
// throw new TipsException("获取小程序Token异常!"); |
|
181 |
// } |
|
182 |
// if(StringUtils.isEmpty(corpMpToken)){ |
|
183 |
// throw new TipsException("获取企业应用小程序Token异常!"); |
|
184 |
// } |
|
185 |
// TreatUtil.sendTreatNoticeShopMic(commonService, visitOrder, TreatUtil.NOTICE_TYPE_ADD, "1000050", mpToken, corpMpToken, doctorName, projectNameSb.toString()); |
|
186 |
// }catch (Exception e){ |
|
187 |
// logger.error("新增治疗单发送企业消息失败:{}", e.getMessage()); |
|
188 |
// logger.error(GlobalExceptionHandler.getExceptionInformation(e)); |
|
189 |
// } |
d6e1c5
|
190 |
// } |
1c1cdf
|
191 |
|
2cfe2a
|
192 |
} |
F |
193 |
|
|
194 |
/** 编辑治疗通知单 */ |
|
195 |
@Override |
|
196 |
public void edit(TreatSingle treatSingle, List<TreatProject> projectList, VisitOrder visitOrder |
|
197 |
, EmployeeRole employeeRole, TreatSingle updateTreat, List<TreatSingleSign> signList) { |
|
198 |
|
|
199 |
SqlSentence sqlSentence = new SqlSentence(); |
|
200 |
Map<String, Object> values = new HashMap<>(); |
|
201 |
sqlSentence.setM(values); |
|
202 |
StringBuffer sql = new StringBuffer(); |
|
203 |
|
|
204 |
//判断查询操作员工信息 |
|
205 |
Employee employee; |
|
206 |
// employee = employeeMapper.selectOneByKey(treatSingle.getOperatorId()); |
0ac137
|
207 |
// if (employee == null) { |
F |
208 |
// throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到操作人的信息[02]:" + treatSingle.getOperatorId()); |
|
209 |
// } |
|
210 |
// values.put("operatorName", employee.getCnName()); |
|
211 |
// values.put("operatorId", employee.getId()); |
2cfe2a
|
212 |
|
F |
213 |
|
|
214 |
//判断查询操作员工门店信息 |
|
215 |
Shop shop = shopMapper.selectOneByKey(treatSingle.getShopId()); |
|
216 |
if (shop == null) { |
|
217 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到操作人门店信息" + treatSingle.getShopId()); |
|
218 |
} |
|
219 |
values.put("shopName", shop.getName()); |
|
220 |
values.put("shopId", shop.getId()); |
|
221 |
|
|
222 |
//判断查询开单人 |
|
223 |
employee = employeeMapper.selectOneByKey(treatSingle.getDeveloperId()); |
|
224 |
if (employee == null) { |
|
225 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到开单人的信息" + treatSingle.getDeveloperId()); |
|
226 |
} |
|
227 |
values.put("developerName", employee.getCnName()); |
|
228 |
values.put("developerId", employee.getId()); |
|
229 |
|
|
230 |
//判断查询开单人门店信息 |
|
231 |
shop = shopMapper.selectOneByKey(treatSingle.getDeveloperShopId()); |
|
232 |
if (shop == null) { |
|
233 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到开单人门店信息" + treatSingle.getDeveloperShopId()); |
|
234 |
} |
|
235 |
values.put("developerShopName", shop.getName()); |
|
236 |
values.put("developerShopId", shop.getId()); |
|
237 |
|
|
238 |
//更改到访订单中的的是否开治疗单状态 |
|
239 |
sql.delete(0, sql.length()); |
|
240 |
if(visitOrder.getIsTreatOrder() == BaseEntity.NO){ |
|
241 |
sql.append(",isTreatOrder = isTreatOrder + 1 "); |
|
242 |
} |
|
243 |
|
|
244 |
if(visitOrder.getStatus() == VisitOrderCommon.WAIT_GT){ |
|
245 |
sql.append(",status = #{m.status} "); |
|
246 |
values.put("status", VisitOrderCommon.STATUS_DISTRIBUTIVE_TREAT); |
|
247 |
} |
|
248 |
|
|
249 |
if(sql.length() > 0){ |
|
250 |
values.put("id", visitOrder.getId()); |
|
251 |
sql.append(" , editTime = now() where id = #{m.id} "); |
|
252 |
sqlSentence.setSqlSentence( sql.toString().replaceFirst(",", "")); |
|
253 |
if (visitOrderMapper.updateWhere(sqlSentence) != 1) { |
|
254 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "修改治疗通知单:更新到访订单状态失败!"); |
|
255 |
} |
|
256 |
} |
|
257 |
|
|
258 |
//修改治疗通知单 |
|
259 |
values.put("remarkInfo", treatSingle.getRemarkInfo()); |
|
260 |
values.put("id", treatSingle.getId()); |
|
261 |
values.put("status", treatSingle.getStatus()); |
|
262 |
values.put("orderClassify", treatSingle.getOrderClassify()); |
31b49a
|
263 |
values.put("isWillPhoto", treatSingle.getIsWillPhoto()); |
F |
264 |
values.put("allergyInfo", treatSingle.getAllergyInfo()); |
71a9af
|
265 |
values.put("isFirstFm", treatSingle.getIsFirstFm()); |
F |
266 |
values.put("isRd", treatSingle.getIsRd()); |
37022a
|
267 |
values.put("isUserSign", treatSingle.getIsUserSign()); |
2cfe2a
|
268 |
sql.delete(0,sql.length()); |
F |
269 |
//operatorName = #{m.operatorName},operatorId = #{m.operatorId}, |
|
270 |
sql.append(" developerName = #{m.developerName},developerId = #{m.developerId},remarkInfo = #{m.remarkInfo} "); |
d9a6e0
|
271 |
sql.append(" ,developerShopName = #{m.developerShopName},developerShopId = #{m.developerShopId} "); |
F |
272 |
sql.append(" ,shopName = #{m.shopName},shopId = #{m.shopId},status = #{m.status} "); |
31b49a
|
273 |
sql.append(" , orderClassify = #{m.orderClassify}, isWillPhoto = #{m.isWillPhoto}, allergyInfo = #{m.allergyInfo} "); |
1930e1
|
274 |
sql.append(" , isFirstFm = #{m.isFirstFm}, isRd = #{m.isRd}, isUserSign = #{m.isUserSign} "); |
2cfe2a
|
275 |
sql.append(" where id = #{m.id} "); |
F |
276 |
sqlSentence.setSqlSentence(sql.toString()); |
|
277 |
if (treatSingleMapper.updateWhere(sqlSentence) != 1) { |
|
278 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "修改失败!"); |
|
279 |
} |
|
280 |
|
|
281 |
//获取编辑治疗单信息变化日志信息 |
|
282 |
StringBuffer logInfo = TreatSingleLogTool.editLogInfo(treatSingle, updateTreat); |
|
283 |
|
|
284 |
|
|
285 |
//出来治疗通知单项目信息 ----------------------------------------------- |
d6e1c5
|
286 |
Map<String, Object> pMap = handleEditProject(treatSingle, projectList, logInfo); |
2cfe2a
|
287 |
|
F |
288 |
//处理治疗单签名------------------------------------------------------------------------- |
502947
|
289 |
handleSignData(signList, treatSingle.getId(), true, employeeRole); |
2cfe2a
|
290 |
|
F |
291 |
//新增治疗单日志 |
|
292 |
TreatSingleLogTool.addLog(commonService, TreatSingleConstants.LOG_TYPE_EDIT, treatSingle, employeeRole, logInfo.toString()); |
|
293 |
|
|
294 |
//----------------------------------------------------------------------- |
8b4156
|
295 |
//发送企业微信修改之前的医生、护士、MIC,药房企业微信通知 |
ad0ff1
|
296 |
//当状态是已确认或者待确认时 需要通知(正式环境才发) |
F |
297 |
if ((treatSingle.getStatus()==TreatSingleConstants.STATUS_WAIT_CONFIRM |
|
298 |
|| treatSingle.getStatus() == TreatSingleConstants.STATUS_CONFIRM ) |
|
299 |
&& PlatformPattern.PROD.equals(customParameter.getPlatformPattern())) { |
d6e1c5
|
300 |
try{ |
1fb1a2
|
301 |
String mpToken = WeiXinMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId()); |
d6e1c5
|
302 |
String corpMpToken = WeiXinCorpMpUtil.getAccessToken(commonService, customParameter.getCorpMpAppId()); |
F |
303 |
if(StringUtils.isEmpty(mpToken)){ |
|
304 |
throw new TipsException("获取小程序Token异常!"); |
|
305 |
} |
|
306 |
if(StringUtils.isEmpty(corpMpToken)){ |
|
307 |
throw new TipsException("获取企业应用小程序Token异常!"); |
|
308 |
} |
a935af
|
309 |
TreatUtil.editTreatNotice2(commonService, visitOrder, treatSingle , "1000050", corpMpToken, mpToken); |
d6e1c5
|
310 |
}catch (Exception e){ |
F |
311 |
logger.error("编辑治疗单发送企业消息失败:{}", e.getMessage()); |
ad0ff1
|
312 |
logger.error(GlobalExceptionHandler.getExceptionInformation(e)); |
d6e1c5
|
313 |
} |
2cfe2a
|
314 |
} |
F |
315 |
|
|
316 |
} |
|
317 |
|
|
318 |
/** 作废治疗通知单 */ |
|
319 |
public void invalidTreat(TreatSingle treatSingle, VisitOrder visitOrder, EmployeeRole employeeRole) { |
|
320 |
|
|
321 |
User user = commonDao.selectOneByKey(UserMapper.class, visitOrder.getUserId()); |
|
322 |
if(user == null){ |
|
323 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到客户信息!"); |
|
324 |
} |
|
325 |
|
|
326 |
Shop shop = commonDao.selectOneByKey(ShopMapper.class, visitOrder.getShopId()); |
|
327 |
if(shop == null){ |
|
328 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到门店信息!"); |
|
329 |
} |
|
330 |
|
|
331 |
SqlSentence sqlSentence = new SqlSentence(); |
|
332 |
Map<String, Object> values = new HashMap<>(); |
|
333 |
sqlSentence.setM(values); |
|
334 |
values.put("treatSingleId", treatSingle.getId()); |
|
335 |
|
|
336 |
//查询治疗通知单项目列表 |
|
337 |
sqlSentence.setSqlSentence(" select id, projectName, hisId from treat_project where isDel = 0 and treatSingleId = #{m.treatSingleId} "); |
|
338 |
List<Map<String, Object>> tpList = treatProjectMapper.selectListMap(sqlSentence); |
|
339 |
|
|
340 |
StringBuffer sb = new StringBuffer(); |
|
341 |
if(tpList != null && tpList.size() > 0){ |
eb8351
|
342 |
sqlSentence.setSqlSentence("SELECT e.id, e.cnName, e.userId, d.type from treat_project_doctor d left join employee e on e.id = d.commonId where d.isDel=0 and d.treatSingleId = #{m.treatSingleId} and d.treatProjectId = #{m.treatProjectId} "); |
2cfe2a
|
343 |
List<Map<String, Object>> treatProjectDoctors ; |
3be6a1
|
344 |
for(Map<String, Object> m : tpList) { |
2cfe2a
|
345 |
sb.append(m.get("projectName")).append(";"); |
F |
346 |
//查询项目对应多个医生或护士 |
eb8351
|
347 |
values.put("treatProjectId", m.get("id")); |
2cfe2a
|
348 |
treatProjectDoctors = treatProjectDoctorMapper.selectListMap(sqlSentence); |
F |
349 |
if(treatProjectDoctors != null && treatProjectDoctors.size() > 0){ |
|
350 |
m.put("eList", treatProjectDoctors); |
|
351 |
} |
|
352 |
} |
|
353 |
|
|
354 |
//对应作废处理关联划扣数据逻辑 |
|
355 |
invalidTreatUpdateDeductData(tpList); |
|
356 |
} |
|
357 |
|
|
358 |
//删除治疗单 |
3be6a1
|
359 |
values.put("status", TreatSingleConstants.STATUS_CANCEL); |
F |
360 |
sqlSentence.setSqlSentence(" status = #{m.status}, isDel = 1, editTime = now() where id = #{m.treatSingleId} "); |
2cfe2a
|
361 |
if (treatSingleMapper.updateWhere(sqlSentence)!= 1) { |
3be6a1
|
362 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "作废治疗通知单失败!"); |
2cfe2a
|
363 |
} |
F |
364 |
|
3be6a1
|
365 |
// sqlSentence.setSqlSentence(" isDel = 1 where treatSingleId = #{m.treatSingleId} and isDel = 0 "); |
F |
366 |
// //删除治疗单项目等信息 |
|
367 |
// treatProjectMapper.updateWhere(sqlSentence); |
eb8351
|
368 |
// //删除治疗单医生信息 |
F |
369 |
// treatProjectDoctorMapper.updateWhere(sqlSentence); |
|
370 |
// //删除治疗通知单项目部分信息 |
|
371 |
// treatBodyPartMapper.updateWhere(sqlSentence); |
2cfe2a
|
372 |
|
F |
373 |
values.put("id", visitOrder.getId()); |
|
374 |
sqlSentence.sqlUpdate(" isTreatOrder = isTreatOrder - 1 WHERE id = #{m.id} ", values); |
|
375 |
if (visitOrderMapper.updateWhere(sqlSentence) != 1) { |
|
376 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "修改到访订单信息失败!"); |
|
377 |
} |
|
378 |
|
eb8351
|
379 |
Integer oldStatus = visitOrder.getStatus(); |
F |
380 |
Integer newStatus = visitOrder.getStatus(); |
|
381 |
|
|
382 |
|
2cfe2a
|
383 |
//新增日志 |
F |
384 |
VLatelyLogTool.addV3(VisitOrderLogConstants.LOG_TYPE_DEL_TREAT_SINGLE, oldStatus, newStatus,"作废治疗通知单", "作废治疗通知单(导医)",employeeRole,visitOrder.getId(),visitOrder.getShopId(),visitOrder.getUserId(), commonDao); |
|
385 |
VGuideLogTool.addV3(VisitOrderLogConstants.LOG_TYPE_DEL_TREAT_SINGLE, oldStatus, newStatus, visitOrder.getPreStartTime(),new Date(),0,"作废治疗通知单(导医)",employeeRole,visitOrder.getId(),visitOrder.getShopId(),visitOrder.getUserId(),commonDao); |
eb8351
|
386 |
|
F |
387 |
//新增治疗单日志 |
|
388 |
TreatSingleLogTool.addLog(commonService, TreatSingleConstants.LOG_TYPE_CANCEL, treatSingle, employeeRole, null); |
2cfe2a
|
389 |
|
F |
390 |
try{ |
|
391 |
BaseConfig baseConfig = new BaseConfig(); |
af7b07
|
392 |
baseConfig.setCorpId(customParameter.getCorpMpAppId()); |
2cfe2a
|
393 |
baseConfig.setCorpMpSecret(customParameter.getCorpMpSecret()); |
F |
394 |
//发送通知 |
|
395 |
TreatNoticeUtil.treatNoticeCancelSendMsg(visitOrder, user, shop, sb.toString(),tpList, baseConfig, commonDao); |
751ac6
|
396 |
}catch (TipsException|PlatTipsException e){ |
C |
397 |
logger.error("作废治疗通知单发送企业通知失败:{}", e.getMessage()); |
2cfe2a
|
398 |
}catch (Exception e){ |
F |
399 |
logger.error("作废治疗通知单发送企业通知失败:{}", GlobalExceptionHandler.getExceptionInformation(e)); |
|
400 |
} |
|
401 |
} |
|
402 |
|
71332a
|
403 |
/** 更新治疗单签名 */ |
F |
404 |
@Override |
|
405 |
public void updateSign(TreatSingle treatSingle, List<TreatSingleSign> signList, EmployeeRole employeeRole) { |
|
406 |
SqlSentence sqlSentence = new SqlSentence(); |
|
407 |
Map<String, Object> values = new HashMap<>(); |
|
408 |
sqlSentence.setM(values); |
|
409 |
values.put("treatSingleId", treatSingle.getId()); |
|
410 |
|
|
411 |
|
|
412 |
StringBuffer logInfo = new StringBuffer(); |
|
413 |
logInfo.append("更新签名类型:"); |
37022a
|
414 |
Integer isUseSign = treatSingle.getIsUserSign(); |
71332a
|
415 |
for(TreatSingleSign sign : signList){ |
eb8351
|
416 |
|
F |
417 |
//类型 |
71332a
|
418 |
values.put("signPerType", sign.getSignPerType()); |
eb8351
|
419 |
//删除旧的 |
F |
420 |
sqlSentence.setSqlSentence(" isDel = 1, editTime = now() where isDel = 0 and treatSingleId = #{m.treatSingleId} and signPerType = #{m.signPerType} "); |
|
421 |
commonService.updateWhere(TreatSingleSignMapper.class, sqlSentence); |
|
422 |
|
|
423 |
//新增 |
|
424 |
sign.setTreatSingleId(treatSingle.getId()); |
502947
|
425 |
sign.setOpId(employeeRole.getEmployeeId()); |
F |
426 |
sign.setOpMan(employeeRole.getCnName()); |
|
427 |
sign.setOpRoleId(employeeRole.getId()); |
|
428 |
sign.setOpShopId(employeeRole.getShopId()); |
|
429 |
sign.setOpRoleStr(employeeRole.getRoleUniqueStr()); |
eb8351
|
430 |
if(commonService.insert(TreatSingleSignMapper.class, sign) != 1){ |
F |
431 |
throw new TipsException("新增治疗单签名失败!"); |
71332a
|
432 |
} |
F |
433 |
|
37022a
|
434 |
//判断用户是否签名 |
F |
435 |
if(TreatSingleSign.SIGN_PER_TYPE_USER.equals(sign.getSignPerType())){ |
|
436 |
isUseSign = BaseEntity.YES; |
|
437 |
} |
|
438 |
|
71332a
|
439 |
//拼接日志 |
F |
440 |
logInfo.append(TreatSingleSign.signPerTypeCh(sign.getSignPerType())).append("、"); |
|
441 |
} |
|
442 |
logInfo.delete(logInfo.length() - 1, logInfo.length()); |
|
443 |
|
37022a
|
444 |
//更新治疗单是否用户已签名 |
F |
445 |
if(treatSingle.getIsUserSign() == BaseEntity.NO && isUseSign == BaseEntity.YES){ |
|
446 |
values.put("id", treatSingle.getId()); |
94a257
|
447 |
sqlSentence.setSqlSentence(" isUserSign = 1 where id = #{m.id} "); |
37022a
|
448 |
if(treatSingleMapper.updateWhere(sqlSentence) != 1){ |
F |
449 |
throw new TipsException("更新治疗单签名失败!"); |
|
450 |
} |
|
451 |
} |
|
452 |
|
71332a
|
453 |
//新增治疗单日志 |
F |
454 |
TreatSingleLogTool.addLog(commonService, TreatSingleConstants.LOG_TYPE_EDIT_SIGN, treatSingle, employeeRole, logInfo.toString()); |
|
455 |
|
|
456 |
} |
2cfe2a
|
457 |
|
ef962a
|
458 |
/**处理用户科室关系*/ |
F |
459 |
@Override |
|
460 |
public void doctorRoomHandler(String treatSingleId) { |
|
461 |
logger.info("-----新增治疗单,多线程处理用户科室关系----"); |
|
462 |
TreatSingle treatSingle = treatSingleMapper.selectOneByKey(treatSingleId); |
|
463 |
if (treatSingle == null){ |
f41f4a
|
464 |
logger.info("新增治疗单处理科室关系,查询治疗单失败"+treatSingleId); |
ef962a
|
465 |
return; |
F |
466 |
} |
|
467 |
if (StringUtils.isEmpty(treatSingle.getUserId())){ |
f41f4a
|
468 |
logger.info("新增治疗单处理科室关系,用户id为空"); |
ef962a
|
469 |
return; |
F |
470 |
} |
8d7468
|
471 |
User user = userMapper.selectOneByKey(treatSingle.getUserId()); |
F |
472 |
if (user == null){ |
f41f4a
|
473 |
logger.info("新增治疗单处理科室关系,查询用户失败"+treatSingle.getUserId()); |
8d7468
|
474 |
return; |
F |
475 |
} |
ef962a
|
476 |
SqlSentence sqlSentence = new SqlSentence(); |
F |
477 |
Map<String,Object> sqlMap = new HashMap<>(); |
|
478 |
sqlMap.put("isDel",BaseEntity.NO); |
|
479 |
sqlMap.put("userId",treatSingle.getUserId()); |
|
480 |
sqlMap.put("treatSingleId",treatSingleId); |
|
481 |
sqlMap.put("type","doctor"); |
|
482 |
sqlSentence.sqlSentence("SELECT * FROM user_families_room WHERE isDel = #{m.isDel} " + |
|
483 |
" AND userId = #{m.userId} AND familiesRoomName IN ('注射科','皮肤科') ",sqlMap); |
|
484 |
List<UserFamiliesRoom> userFamiliesRoomList = userFamiliesRoomMapper.selectList(sqlSentence); |
|
485 |
Map<String,UserFamiliesRoom> dataMap = new HashMap<>(); |
|
486 |
if (userFamiliesRoomList != null && userFamiliesRoomList.size() > 0){ |
|
487 |
for (UserFamiliesRoom userFamiliesRoom : userFamiliesRoomList) { |
|
488 |
dataMap.put(userFamiliesRoom.getFamiliesRoomId(),userFamiliesRoom); |
|
489 |
} |
|
490 |
} |
|
491 |
sqlSentence.sqlSentence("SELECT * FROM treat_project_doctor WHERE isDel = #{m.isDel} " + |
|
492 |
" AND treatSingleId = #{m.treatSingleId} AND type = #{m.type} ",sqlMap); |
|
493 |
List<TreatProjectDoctor> treatProjectDoctorList = treatProjectDoctorMapper.selectList(sqlSentence); |
|
494 |
if (treatProjectDoctorList != null && treatProjectDoctorList.size() > 0){ |
b28e35
|
495 |
//去重map(科室标识,数据) |
F |
496 |
List<String> checkList = new ArrayList<>(); |
ef962a
|
497 |
for (TreatProjectDoctor treatProjectDoctor : treatProjectDoctorList) { |
F |
498 |
if (StringUtils.isEmpty(treatProjectDoctor.getDepartmentId())){ |
|
499 |
continue; |
|
500 |
} |
b28e35
|
501 |
if (checkList.contains(treatProjectDoctor.getDepartmentId())){ |
F |
502 |
logger.info("新增治疗单处理科室关系,重复的科室关系,跳过处理:"+treatProjectDoctor.getDepartmentId()); |
|
503 |
continue; |
|
504 |
} |
|
505 |
//查询科室 |
ef962a
|
506 |
UserFamiliesRoom mapData = dataMap.get(treatProjectDoctor.getDepartmentId()); |
f5dbf3
|
507 |
if (mapData != null){ |
F |
508 |
logger.info("新增治疗单处理科室关系,已存在科室关系,跳过处理:"+mapData.getFamiliesRoomName()); |
|
509 |
continue; |
|
510 |
} |
|
511 |
logger.info("新增治疗单处理科室关系,治疗单医生数据:"+JSON.toJSONString(treatProjectDoctor)); |
|
512 |
FamiliesRoom familiesRoom = familiesRoomMapper.selectOneByKey(treatProjectDoctor.getDepartmentId()); |
|
513 |
//找不到科室信息不处理 |
|
514 |
if (familiesRoom == null){ |
|
515 |
logger.info("新增治疗单处理科室关系,查询科室失败,跳过处理:"+treatProjectDoctor.getDepartmentId()); |
|
516 |
continue; |
|
517 |
} |
|
518 |
//不是皮肤科和注射科不处理 |
|
519 |
if (!"注射科".equals(familiesRoom.getFamiliesRoomName()) && !"皮肤科".equals(familiesRoom.getFamiliesRoomName())){ |
|
520 |
logger.info("新增治疗单处理科室关系,非注射科和皮肤科,跳过处理:"+familiesRoom.getFamiliesRoomName()); |
|
521 |
continue; |
|
522 |
} |
|
523 |
UserFamiliesRoom userFamiliesRoom = new UserFamiliesRoom(); |
|
524 |
userFamiliesRoom.setUserId(treatSingle.getUserId()); |
|
525 |
userFamiliesRoom.setFamiliesRoomId(treatProjectDoctor.getDepartmentId()); |
|
526 |
userFamiliesRoom.setFamiliesRoomName(familiesRoom.getFamiliesRoomName()); |
|
527 |
userFamiliesRoom.setDoctorId(treatProjectDoctor.getCommonId()); |
|
528 |
Employee employee = employeeMapper.selectOneByKey(treatProjectDoctor.getCommonId()); |
|
529 |
if (employee != null){ |
|
530 |
userFamiliesRoom.setDoctorName(employee.getCnName()); |
|
531 |
} |
|
532 |
userFamiliesRoom.setIsDefault(0); |
|
533 |
if (userFamiliesRoomMapper.insert(userFamiliesRoom) != 1){ |
|
534 |
throw new TipsException("新增失败1!"+ JSON.toJSONString(userFamiliesRoom)); |
|
535 |
} |
|
536 |
//新增修改记录 |
|
537 |
UserBeChangeLog userBeChangeLog = new UserBeChangeLog(); |
|
538 |
userBeChangeLog.setUserId(user.getId()); |
|
539 |
userBeChangeLog.setUserName(user.getName()); |
|
540 |
userBeChangeLog.setUserLevel(user.getUserLevel()); |
|
541 |
userBeChangeLog.setUserType(user.getUserType()); |
|
542 |
userBeChangeLog.setUserStatus(user.getUserStatus()); |
|
543 |
userBeChangeLog.setHisCorpUserId(user.getHisCorpUserId()); |
|
544 |
userBeChangeLog.setBelongShopId(user.getShopId()); |
|
545 |
userBeChangeLog.setMemberNO(user.getMemberNO()); |
|
546 |
userBeChangeLog.setCIQ(user.getCIQ()); |
|
547 |
userBeChangeLog.setChangeType(UserBeChangeLog.CHANGE_TYPE_ROOM_DOCTOR); |
|
548 |
userBeChangeLog.setCommonId(treatProjectDoctor.getCommonId()); |
|
549 |
if (employee != null){ |
|
550 |
userBeChangeLog.setCommonValue(employee.getCnName()); |
|
551 |
} |
|
552 |
userBeChangeLog.setRoomId(treatProjectDoctor.getDepartmentId()); |
|
553 |
userBeChangeLog.setRoomName(familiesRoom.getFamiliesRoomName()); |
|
554 |
userBeChangeLog.setRemark("治疗单:"+treatSingle.getTreatSingleNo()); |
|
555 |
if (userBeChangeLogMapper.insert(userBeChangeLog) != 1){ |
|
556 |
throw new TipsException("新增失败2!"+ JSON.toJSONString(userBeChangeLog)); |
ef962a
|
557 |
} |
b28e35
|
558 |
|
F |
559 |
checkList.add(treatProjectDoctor.getDepartmentId()); |
ef962a
|
560 |
} |
F |
561 |
} |
|
562 |
} |
|
563 |
|
2cfe2a
|
564 |
|
7e52f3
|
565 |
/** 处理治疗单模式数据 */ |
F |
566 |
public void handleModeData(List<TreatProject> treatProjectList){ |
|
567 |
//先过滤出打法不为空的治疗单项目:项目名,打法 |
|
568 |
Map<String, String> dataMap = treatProjectList.stream().filter(s->StringUtils.noNull(s.getItemMode())).collect(Collectors.toMap(TreatProject::getProjectName, TreatProject::getItemMode)); |
|
569 |
if(dataMap == null || dataMap.size() < 1){ |
|
570 |
return; |
|
571 |
} |
|
572 |
|
|
573 |
SystemParameter sp = systemParameterMapper.selectOneByName(SystemParameter.KEY_ZLD_PROJECT_MODE_DATA); |
|
574 |
List<TreatProjectModeDataVo> modeDataVoList = null; |
|
575 |
if(sp != null && StringUtils.isEmpty(sp.getParamValue())){ |
|
576 |
modeDataVoList = JSONArray.parseArray(sp.getParamValue(), TreatProjectModeDataVo.class); |
|
577 |
} |
|
578 |
|
|
579 |
if(modeDataVoList == null){ |
|
580 |
modeDataVoList = new ArrayList<>(); |
|
581 |
} |
|
582 |
|
|
583 |
TreatProjectModeDataVo modeDataVo; |
|
584 |
for(Map.Entry<String, String> entry : dataMap.entrySet()){ |
|
585 |
//没有时则 |
|
586 |
if(modeDataVoList.size() == 0){ |
|
587 |
modeDataVoList.add(new TreatProjectModeDataVo(entry.getKey(), entry.getValue())); |
|
588 |
continue; |
|
589 |
|
|
590 |
} |
|
591 |
|
|
592 |
for(int i = 0; i < modeDataVoList.size(); i++){ |
|
593 |
modeDataVo = modeDataVoList.get(i); |
|
594 |
//有相同的项目名数据 |
|
595 |
if(modeDataVo.getProjectName().equals(entry.getKey())){ |
|
596 |
//然后对应的打法不存在 |
|
597 |
if(!modeDataVo.getModeList().contains(entry.getValue())){ |
|
598 |
modeDataVo.getModeList().add(entry.getValue()); |
|
599 |
continue; |
|
600 |
} |
|
601 |
} |
|
602 |
|
|
603 |
//最后一个时表示没匹配到,则新增 |
|
604 |
if(i == modeDataVoList.size() - 1){ |
|
605 |
modeDataVoList.add(new TreatProjectModeDataVo(entry.getKey(), entry.getValue())); |
|
606 |
} |
|
607 |
} |
|
608 |
} |
|
609 |
|
|
610 |
if(modeDataVoList.size() < 1){ |
|
611 |
return; |
|
612 |
} |
|
613 |
|
|
614 |
JSONArray arr = JSONArray.parseArray(JSONObject.toJSONString(modeDataVoList)); |
|
615 |
if(sp == null){ |
|
616 |
sp = new SystemParameter(); |
|
617 |
sp.setParamName(SystemParameter.KEY_ZLD_PROJECT_MODE_DATA); |
|
618 |
sp.setParamValue(arr.toString()); |
|
619 |
systemParameterMapper.insert(sp); |
|
620 |
}else{ |
|
621 |
sp.setParamValue(arr.toString()); |
|
622 |
systemParameterMapper.updateInfoById(sp); |
|
623 |
} |
|
624 |
} |
|
625 |
|
2cfe2a
|
626 |
/////////////////////////////////////////////////////////////////////////////// |
F |
627 |
|
|
628 |
//处理编辑治疗通知单时项目变动逻辑 |
d6e1c5
|
629 |
public Map<String, Object> handleEditProject(TreatSingle treatSingle, List<TreatProject> projectList, StringBuffer logInfo){ |
2cfe2a
|
630 |
|
F |
631 |
SqlSentence sqlSentence = new SqlSentence(); |
|
632 |
Map<String, Object> values = new HashMap<>(); |
|
633 |
sqlSentence.setM(values); |
|
634 |
values.put("id", treatSingle.getId()); |
|
635 |
|
|
636 |
//逻辑删除原治疗通知单人员 |
|
637 |
sqlSentence.setSqlSentence("isDel = 1 where treatSingleId = #{m.id} and isDel = 0 "); |
|
638 |
treatProjectDoctorMapper.updateWhere(sqlSentence); |
|
639 |
|
|
640 |
//查询原治疗通知单项目列表 |
|
641 |
sqlSentence.setSqlSentence(" select * from treat_project where isDel = 0 and treatSingleId = #{m.id} "); |
|
642 |
List<TreatProject> tpList = treatProjectMapper.selectList(sqlSentence); |
|
643 |
Map<String, TreatProject> tpMap = new HashMap<>(); |
|
644 |
if(tpList != null && tpList.size() >= 0){ |
|
645 |
tpMap = tpList.stream().collect(Collectors.toMap(TreatProject::getId, Function.identity())); |
|
646 |
} |
|
647 |
|
|
648 |
//创建新的治疗项目 |
d6e1c5
|
649 |
StringBuffer projectNameSb = new StringBuffer(); |
F |
650 |
String doctorName = null; |
2cfe2a
|
651 |
TreatProject oldTp = null; |
502947
|
652 |
for (TreatProject treatProject : projectList) { |
F |
653 |
treatProject.setTreatSingleId(treatSingle.getId()); |
|
654 |
oldTp = tpMap.get(treatProject.getId()); |
2cfe2a
|
655 |
//原项目 |
F |
656 |
if(oldTp != null){ |
|
657 |
//更新 |
502947
|
658 |
if (treatProjectMapper.updateEditInfo(treatProject) != 1) { |
2cfe2a
|
659 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "修改治疗项目数量失败!"); |
F |
660 |
} |
502947
|
661 |
if(oldTp.getNum() != treatProject.getNum()){ |
F |
662 |
logInfo.append("修改【").append(oldTp.getProjectName()).append(" x ").append(treatProject.getNum()).append("】").append(";"); |
f771ee
|
663 |
} |
2cfe2a
|
664 |
//清除更新后的项目 |
502947
|
665 |
tpMap.remove(treatProject.getId()); |
2cfe2a
|
666 |
}else{ |
F |
667 |
//新项目 |
502947
|
668 |
treatProject.setTreatSingleNo(treatSingle.getTreatSingleNo()); |
F |
669 |
if (treatProjectMapper.insert(treatProject) != 1) { |
2cfe2a
|
670 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "修改时新增治疗项目失败!"); |
F |
671 |
} |
|
672 |
//添加日志内容 |
502947
|
673 |
logInfo.append("新增【").append(treatProject.getProjectName()).append(" x ").append(treatProject.getNum()).append("】").append(";"); |
2cfe2a
|
674 |
} |
F |
675 |
|
|
676 |
//新增项目人员 |
502947
|
677 |
doctorName = addTreatProjectDoctor(treatProject, doctorName); |
2cfe2a
|
678 |
//编辑处理部位信息 |
502947
|
679 |
handleBodyPart(treatProject, true); |
2cfe2a
|
680 |
//处理项目适应症 |
502947
|
681 |
handleTreatProjectIndication(treatProject, true); |
d6e1c5
|
682 |
|
F |
683 |
//拼接项目名 |
502947
|
684 |
projectNameSb.append(projectNameSb.length() > 0 ? "+" : "").append(treatProject.getProjectName()); |
2cfe2a
|
685 |
} |
F |
686 |
|
|
687 |
//删除项目 |
|
688 |
values.clear(); |
|
689 |
List<Map<String, Object>> deductList = null; |
|
690 |
for(Map.Entry<String, TreatProject> tp : tpMap.entrySet()){ |
|
691 |
oldTp = tp.getValue(); |
|
692 |
values.put("treatProjectId", oldTp.getId()); |
|
693 |
//先查询划扣参数 |
|
694 |
sqlSentence.setSqlSentence(" select dp.id as deductionProjectId, ds.id as deductionSingleId, ds.treatSingleId from deduction_project dp left join deduction_single ds on ds.id = dp.deductionSingleId where dp.treatProjectId = #{m.treatProjectId} "); |
|
695 |
deductList = commonDao.selectListMap(DeductionProjectMapper.class, sqlSentence); |
|
696 |
if(deductList != null && deductList.size() > 0){ |
|
697 |
//清空划扣记录的关联 |
|
698 |
for(Map<String, Object> deduct : deductList){ |
|
699 |
//划扣项目 |
|
700 |
if(deduct.containsKey("deductionProjectId") && !StringUtils.isEmpty(deduct.get("deductionProjectId").toString())){ |
|
701 |
values.put("deductionProjectId", deduct.get("deductionProjectId")); |
|
702 |
sqlSentence.setSqlSentence(" treatProjectId = null where id = #{m.deductionProjectId} "); |
|
703 |
if(commonDao.updateWhere(DeductionProjectMapper.class, sqlSentence) != 1){ |
|
704 |
throw new TipsException("编辑治疗通知单:清除划扣项目关联id失败!" + deduct.get("deductionProjectId")); |
|
705 |
} |
|
706 |
} |
|
707 |
|
|
708 |
//划扣记录 |
|
709 |
if(deduct.containsKey("deductionSingleId") && !StringUtils.isEmpty(deduct.get("deductionSingleId").toString())){ |
|
710 |
values.put("deductionSingleId", deduct.get("deductionSingleId")); |
|
711 |
sqlSentence.setSqlSentence(" treatSingleId = null where id = #{m.deductionSingleId} "); |
|
712 |
if(commonDao.updateWhere(DeductionSingleMapper.class, sqlSentence) != 1){ |
|
713 |
// throw new TipsException("编辑治疗通知单:清除划扣记录关联id失败!"); |
|
714 |
} |
|
715 |
} |
|
716 |
} |
|
717 |
} |
|
718 |
|
|
719 |
//删除治疗通知单项目 |
|
720 |
sqlSentence.setSqlSentence(" isDel = 1 where id = #{m.treatProjectId} "); |
|
721 |
if(treatProjectMapper.updateWhere(sqlSentence) != 1){ |
|
722 |
throw new TipsException("编辑治疗通知单:更新删除治疗通知单项目失败!" + oldTp.getId()); |
|
723 |
} |
|
724 |
//添加日志内容 |
|
725 |
logInfo.append("将【").append(oldTp.getProjectName()).append("】项目删除"); |
|
726 |
} |
d6e1c5
|
727 |
|
F |
728 |
//返回要使用参数 |
|
729 |
values.clear(); |
|
730 |
values.put("projectName", projectNameSb.toString()); |
|
731 |
values.put("doctorName", doctorName); |
|
732 |
return values; |
2cfe2a
|
733 |
} |
F |
734 |
|
|
735 |
//新增治疗通知单项目人员 |
d6e1c5
|
736 |
public String addTreatProjectDoctor(TreatProject treatProject, String doctorName) { |
2cfe2a
|
737 |
// 如果项目人员为空 |
F |
738 |
List<TreatProjectDoctor> treatProjectDoctorList = treatProject.getTreatProjectDoctorList(); |
|
739 |
if (treatProjectDoctorList == null || treatProjectDoctorList.size() < 1) { |
d6e1c5
|
740 |
return doctorName; |
2cfe2a
|
741 |
} |
d6e1c5
|
742 |
// if (treatProjectDoctorList == null || treatProjectDoctorList.size() < 1) { |
F |
743 |
// //如果新对象字段为空,走旧字段逻辑 |
|
744 |
// // 如果项目人员为空 |
|
745 |
// List<String> doctorIds = treatProject.getDoctorIds(); |
|
746 |
// if(doctorIds == null || doctorIds.size() < 1){ |
|
747 |
// return null; |
|
748 |
// } |
|
749 |
// |
|
750 |
// //获取人员id数组 |
|
751 |
// TreatProjectDoctor treatProjectDoctor; |
|
752 |
// for(String doctorId : doctorIds){ |
|
753 |
// treatProjectDoctor = new TreatProjectDoctor(); |
|
754 |
// treatProjectDoctor.setType(RoleType.UNIQUE_STR_DOCTOR); |
|
755 |
// treatProjectDoctor.setTreatSingleId(treatProject.getTreatSingleId()); |
|
756 |
// treatProjectDoctor.setTreatProjectHisId(treatProject.getHisId()); |
|
757 |
// treatProjectDoctor.setTreatProjectId(treatProject.getId()); |
|
758 |
// treatProjectDoctor.setCommonId(doctorId); |
|
759 |
// treatProjectDoctorMapper.insert(treatProjectDoctor); |
|
760 |
// } |
|
761 |
// return null; |
|
762 |
// } |
2cfe2a
|
763 |
|
F |
764 |
// 获取人员对象 |
|
765 |
for (TreatProjectDoctor treatProjectDoctor : treatProjectDoctorList) { |
d6e1c5
|
766 |
//如果医生名称为空,则查询获取一个 |
F |
767 |
if(StringUtils.isEmpty(doctorName)){ |
|
768 |
doctorName = EmployeeTool.getCnName(treatProjectDoctor.getCommonId(), commonService); |
|
769 |
} |
2cfe2a
|
770 |
treatProjectDoctor.setType(RoleType.UNIQUE_STR_DOCTOR); |
F |
771 |
treatProjectDoctor.setTreatSingleId(treatProject.getTreatSingleId()); |
|
772 |
treatProjectDoctor.setTreatProjectHisId(treatProject.getHisId()); |
|
773 |
treatProjectDoctor.setTreatProjectId(treatProject.getId()); |
|
774 |
// 主诊医生信息处理 |
|
775 |
if (!StringUtils.isEmpty(treatProjectDoctor.getPrimaryDoctorId())) { |
|
776 |
Employee employee = employeeMapper.selectOneByKey(treatProjectDoctor.getPrimaryDoctorId()); |
|
777 |
if (employee == null) { |
|
778 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "主诊医生信息不存在!"); |
|
779 |
} |
|
780 |
} |
|
781 |
// 治疗医生处理 |
|
782 |
if (!StringUtils.isEmpty(treatProjectDoctor.getCommonId())) { |
|
783 |
Employee employee = employeeMapper.selectOneByKey(treatProjectDoctor.getCommonId()); |
|
784 |
if (employee == null) { |
|
785 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "治疗医生信息不存在!"); |
|
786 |
} |
|
787 |
} |
|
788 |
treatProjectDoctorMapper.insert(treatProjectDoctor); |
|
789 |
} |
d6e1c5
|
790 |
return doctorName; |
2cfe2a
|
791 |
} |
F |
792 |
|
|
793 |
//处理项目选择部位数据 |
|
794 |
public void handleBodyPart(TreatProject treatProject, boolean isEdit){ |
|
795 |
List<TreatBodyPart> bpList = treatProject.getBpList(); |
|
796 |
if(bpList == null ){ |
|
797 |
bpList = new ArrayList<>(); |
|
798 |
} |
|
799 |
|
|
800 |
Map<String, String> oldMap = new HashMap<>(); |
|
801 |
//编辑时,查询原治疗单项目部分信息 |
|
802 |
if(isEdit){ |
|
803 |
List<TreatBodyPart> oldList = treatBodyPartMapper.selectListByTreatProjectId(treatProject.getId()); |
|
804 |
if(oldList != null && oldList.size() > 0){ |
|
805 |
oldMap = oldList.stream().collect(Collectors.toMap(TreatBodyPart::getBodyPartItemId, TreatBodyPart::getId)); |
|
806 |
} |
|
807 |
} |
|
808 |
|
|
809 |
//遍历处理 |
|
810 |
for(TreatBodyPart treatBodyPart : bpList){ |
|
811 |
if(oldMap.containsKey(treatBodyPart.getBodyPartItemId())){ |
502947
|
812 |
//更新其他信息 |
F |
813 |
treatBodyPart.setId(oldMap.get(treatBodyPart.getBodyPartItemId())); |
|
814 |
treatBodyPartMapper.updateOtherInfo(treatBodyPart); |
2cfe2a
|
815 |
oldMap.remove(treatBodyPart.getBodyPartItemId()); |
F |
816 |
continue; |
|
817 |
} |
|
818 |
//新增 |
|
819 |
treatBodyPart.setTreatSingleId(treatProject.getTreatSingleId()); |
|
820 |
treatBodyPart.setTreatProjectId(treatProject.getId()); |
|
821 |
if(treatBodyPartMapper.insert(treatBodyPart) != 1){ |
|
822 |
throw new TipsException("新增治疗单项目部位信息失败!"); |
|
823 |
} |
|
824 |
} |
|
825 |
|
|
826 |
//删除 |
|
827 |
if(oldMap.size() > 0){ |
|
828 |
for(Map.Entry<String, String> entry : oldMap.entrySet()){ |
|
829 |
treatBodyPartMapper.updateDelById(entry.getValue()); |
|
830 |
} |
|
831 |
} |
|
832 |
} |
|
833 |
|
|
834 |
//处理项目适应症数据 |
|
835 |
public void handleTreatProjectIndication(TreatProject treatProject, boolean isEdit){ |
|
836 |
List<TreatProjectIndication> indicationList = treatProject.getIndicationList(); |
|
837 |
if(indicationList == null){ |
|
838 |
indicationList = new ArrayList<>(); |
|
839 |
} |
|
840 |
|
|
841 |
SqlSentence sqlSentence = new SqlSentence(); |
|
842 |
Map<String, Object> values = new HashMap<>(); |
|
843 |
sqlSentence.setM(values); |
|
844 |
|
|
845 |
Map<String, String> oldMap = new HashMap<>(); |
|
846 |
//编辑时,查询原治疗单项目部分信息 |
|
847 |
if(isEdit){ |
|
848 |
values.put("treatProjectId", treatProject.getId()); |
|
849 |
sqlSentence.setSqlSentence(" select * from treat_project_indication where isDel = 0 and treatProjectId = #{m.treatProjectId} "); |
|
850 |
List<TreatProjectIndication> oldList = commonService.selectList(TreatProjectIndicationMapper.class, sqlSentence); |
|
851 |
if(oldList != null && oldList.size() > 0){ |
|
852 |
oldMap = oldList.stream().collect(Collectors.toMap(TreatProjectIndication::getIndicationId, TreatProjectIndication::getId)); |
|
853 |
} |
|
854 |
} |
|
855 |
|
|
856 |
//遍历处理 |
|
857 |
for(TreatProjectIndication treatProjectIndication : indicationList){ |
|
858 |
if(oldMap.containsKey(treatProjectIndication.getIndicationId())){ |
|
859 |
oldMap.remove(treatProjectIndication.getIndicationId()); |
|
860 |
continue; |
|
861 |
} |
|
862 |
//新增 |
|
863 |
treatProjectIndication.setTreatSingleId(treatProject.getTreatSingleId()); |
|
864 |
treatProjectIndication.setTreatProjectId(treatProject.getId()); |
|
865 |
if(commonService.insert(TreatProjectIndicationMapper.class,treatProjectIndication) != 1){ |
|
866 |
throw new TipsException("新增治疗单项目适应症失败!"); |
|
867 |
} |
|
868 |
} |
|
869 |
|
|
870 |
//删除 |
|
871 |
if(oldMap.size() > 0){ |
|
872 |
values.clear(); |
|
873 |
sqlSentence.setSqlSentence(" isDel = 1, editTime = now() where id = #{m.id} "); |
|
874 |
for(Map.Entry<String, String> entry : oldMap.entrySet()){ |
|
875 |
values.put("id", entry.getValue()); |
|
876 |
commonService.updateWhere(TreatProjectIndicationMapper.class, sqlSentence); |
|
877 |
} |
|
878 |
} |
|
879 |
} |
|
880 |
|
|
881 |
//处理治疗单签名数据 |
502947
|
882 |
public void handleSignData(List<TreatSingleSign> signList, String treatSingleId, boolean isEdit, EmployeeRole employeeRole){ |
2cfe2a
|
883 |
if(signList == null){ |
F |
884 |
signList = new ArrayList<>(); |
|
885 |
} |
|
886 |
|
|
887 |
SqlSentence sqlSentence = new SqlSentence(); |
|
888 |
Map<String, Object> values = new HashMap<>(); |
|
889 |
sqlSentence.setM(values); |
|
890 |
|
|
891 |
//存储删除的信息 |
|
892 |
Map<String, TreatSingleSign> delMap = new HashMap<>(); |
|
893 |
//判断编辑时才查旧数据出来匹配删除 |
|
894 |
if(isEdit){ |
|
895 |
values.put("treatSingleId", treatSingleId); |
|
896 |
sqlSentence.setSqlSentence(" select * from treat_single_sign where isDel = 0 and treatSingleId = #{m.treatSingleId} "); |
|
897 |
List<TreatSingleSign> oldList = commonService.selectList(TreatSingleSignMapper.class, sqlSentence); |
|
898 |
if(oldList != null && oldList.size() > 0){ |
|
899 |
delMap = oldList.stream().collect(Collectors.toMap(TreatSingleSign::getSignPerType, Function.identity())); |
|
900 |
} |
|
901 |
} |
|
902 |
|
|
903 |
TreatSingleSign oldSign; |
|
904 |
sqlSentence.setSqlSentence(" signPerName = #{m.signPerName}, signImg = #{m.signImg}, editTime = now() where id = #{m.id} "); |
|
905 |
|
|
906 |
//遍历 |
|
907 |
for(TreatSingleSign sign : signList){ |
|
908 |
if(delMap.containsKey(sign.getSignPerType())){ |
|
909 |
oldSign = delMap.get(sign.getSignPerType()); |
|
910 |
//判断更新 |
|
911 |
if(!sign.getSignImg().equals(oldSign.getSignImg())){ |
502947
|
912 |
sign.setId(oldSign.getId()); |
F |
913 |
if(treatSingleSignMapper.updateInfo(sign) != 1){ |
2cfe2a
|
914 |
throw new TipsException("更新治疗单签名失败!"); |
F |
915 |
} |
|
916 |
} |
|
917 |
delMap.remove(sign.getSignPerType()); |
|
918 |
}else{ |
|
919 |
//新增 |
|
920 |
sign.setTreatSingleId(treatSingleId); |
502947
|
921 |
sign.setOpId(employeeRole.getEmployeeId()); |
F |
922 |
sign.setOpMan(employeeRole.getCnName()); |
|
923 |
sign.setOpRoleId(employeeRole.getId()); |
|
924 |
sign.setOpShopId(employeeRole.getShopId()); |
|
925 |
sign.setOpRoleStr(employeeRole.getRoleUniqueStr()); |
2cfe2a
|
926 |
if(commonService.insert(TreatSingleSignMapper.class, sign) != 1){ |
F |
927 |
throw new TipsException("新增治疗单签名失败!"); |
|
928 |
} |
|
929 |
} |
|
930 |
} |
|
931 |
|
|
932 |
//删除 |
|
933 |
if(delMap.size() > 0){ |
|
934 |
values.clear(); |
|
935 |
sqlSentence.setSqlSentence(" isDel = 1, editTime = now() where id = #{m.id} "); |
|
936 |
for(Map.Entry<String, TreatSingleSign> entry : delMap.entrySet()){ |
|
937 |
values.put("id", entry.getValue().getId()); |
|
938 |
if(commonService.updateWhere(TreatSingleSignMapper.class, sqlSentence) != 1){ |
|
939 |
throw new TipsException("删除治疗单签名失败!"); |
|
940 |
} |
|
941 |
} |
|
942 |
} |
|
943 |
|
|
944 |
} |
|
945 |
|
|
946 |
//作废处理关联划扣数据逻辑 |
|
947 |
private void invalidTreatUpdateDeductData(List<Map<String, Object>> tpList){ |
|
948 |
SqlSentence sqlSentence = new SqlSentence(); |
|
949 |
Map<String, Object> values = new HashMap<>(); |
|
950 |
sqlSentence.setM(values); |
|
951 |
|
|
952 |
List<Map<String, Object>> deductList = null; |
|
953 |
for(Map<String, Object> tp : tpList){ |
|
954 |
|
|
955 |
values.put("treatProjectId", tp.get("id")); |
|
956 |
//先查询划扣参数 |
|
957 |
sqlSentence.setSqlSentence(" select dp.id as deductionProjectId, ds.id as deductionSingleId, ds.treatSingleId from deduction_project dp left join deduction_single ds on ds.id = dp.deductionSingleId where dp.treatProjectId = #{m.treatProjectId} "); |
|
958 |
deductList = commonDao.selectListMap(DeductionProjectMapper.class, sqlSentence); |
|
959 |
if(deductList != null && deductList.size() > 0){ |
|
960 |
//清空划扣记录的关联 |
|
961 |
for(Map<String, Object> deduct : deductList){ |
|
962 |
//划扣项目 |
|
963 |
if(deduct.containsKey("deductionProjectId") && !StringUtils.isEmpty(deduct.get("deductionProjectId").toString())){ |
|
964 |
values.put("deductionProjectId", deduct.get("deductionProjectId")); |
|
965 |
sqlSentence.setSqlSentence(" treatProjectId = null where id = #{m.deductionProjectId} "); |
|
966 |
if(commonDao.updateWhere(DeductionProjectMapper.class, sqlSentence) != 1){ |
|
967 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "清除划扣项目关联id失败!" + deduct.get("deductionProjectId")); |
|
968 |
} |
|
969 |
} |
|
970 |
|
|
971 |
//划扣记录 |
|
972 |
if(deduct.containsKey("deductionSingleId") && !StringUtils.isEmpty(deduct.get("deductionSingleId").toString())){ |
|
973 |
values.put("deductionSingleId", deduct.get("deductionSingleId")); |
|
974 |
sqlSentence.setSqlSentence(" treatSingleId = null where id = #{m.deductionSingleId} "); |
|
975 |
if(commonDao.updateWhere(com.hx.phiappt.dao.mapper.DeductionSingleMapper.class, sqlSentence) != 1){ |
|
976 |
// throw new TipsException("清除划扣记录关联id失败!"); |
|
977 |
} |
|
978 |
} |
|
979 |
} |
|
980 |
} |
|
981 |
} |
|
982 |
} |
|
983 |
|
|
984 |
|
|
985 |
} |
|
986 |
|