|  | @ -64,13 +64,13 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
 | 
												
													
														
															|  |      * @return
 |  |      * @return
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     @Transactional(rollbackFor = Exception.class)
 |  |     @Transactional(rollbackFor = Exception.class)
 | 
												
													
														
															|  |     public String createDetailOut(String jsonData) {
 |  | 
 | 
												
													
														
															|  | 
 |  |     public JSONObject createDetailOut(String jsonData) {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         JSONObject result = new JSONObject();
 |  |         JSONObject result = new JSONObject();
 | 
												
													
														
															|  |         if(StringUtils.isEmpty(jsonData)){
 |  |         if(StringUtils.isEmpty(jsonData)){
 | 
												
													
														
															|  |             result.put("msg","jsonData is null");
 |  |             result.put("msg","jsonData is null");
 | 
												
													
														
															|  |             result.put("response", ConstantUtils.FAIL);
 |  |             result.put("response", ConstantUtils.FAIL);
 | 
												
													
														
															|  |             return result.toJSONString();
 |  | 
 | 
												
													
														
															|  | 
 |  |             return result;
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         JSONObject out = JSONObject.parseObject(jsonData);
 |  |         JSONObject out = JSONObject.parseObject(jsonData);
 | 
												
											
												
													
														
															|  | @ -79,7 +79,12 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
 | 
												
													
														
															|  |         if (obj == null ) {
 |  |         if (obj == null ) {
 | 
												
													
														
															|  |             result.put("msg", "obj is null!");
 |  |             result.put("msg", "obj is null!");
 | 
												
													
														
															|  |             result.put("response", ConstantUtils.FAIL);
 |  |             result.put("response", ConstantUtils.FAIL);
 | 
												
													
														
															|  |             return result.toJSONString();
 |  | 
 | 
												
													
														
															|  | 
 |  |             return result;
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (outDao.countByUpNum(obj.getUpId()) > 0) {
 | 
												
													
														
															|  | 
 |  |             result.put("msg", "out of this up was create!");
 | 
												
													
														
															|  | 
 |  |             result.put("response", ConstantUtils.FAIL);
 | 
												
													
														
															|  | 
 |  |             return result;
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         //需要补货的设备
 |  |         //需要补货的设备
 | 
												
													
														
															|  |         Mediicinedevice mediicinedevice = deviceDao.findOne(obj.getDeviceId());
 |  |         Mediicinedevice mediicinedevice = deviceDao.findOne(obj.getDeviceId());
 | 
												
											
												
													
														
															|  | @ -98,14 +103,14 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
 | 
												
													
														
															|  |         mediicinestockout.setState("1");
 |  |         mediicinestockout.setState("1");
 | 
												
													
														
															|  |         mediicinestockout.setReplenishInventory(obj.getDrugs().stream().reduce(0, (sum, p) -> sum += p.getQty() , Integer::sum).toString());
 |  |         mediicinestockout.setReplenishInventory(obj.getDrugs().stream().reduce(0, (sum, p) -> sum += p.getQty() , Integer::sum).toString());
 | 
												
													
														
															|  |         //备货单号
 |  |         //备货单号
 | 
												
													
														
															|  |         mediicinestockout.setUpNum(upDao.findOne(obj.getUpId()).getDocNum());
 |  | 
 | 
												
													
														
															|  | 
 |  |         mediicinestockout.setUpNum(obj.getUpId());
 | 
												
													
														
															|  |         outDao.save(mediicinestockout);
 |  |         outDao.save(mediicinestockout);
 | 
												
													
														
															|  |         for (DrugDO drug : obj.getDrugs()) {
 |  |         for (DrugDO drug : obj.getDrugs()) {
 | 
												
													
														
															|  |             Mediicinedrugs mediicinedrugs = drugsDao.findOne(drug.getDrugId());
 |  |             Mediicinedrugs mediicinedrugs = drugsDao.findOne(drug.getDrugId());
 | 
												
													
														
															|  |             Mediicinestockoutdetail mediicinestockoutdetail = new Mediicinestockoutdetail();
 |  |             Mediicinestockoutdetail mediicinestockoutdetail = new Mediicinestockoutdetail();
 | 
												
													
														
															|  |             mediicinestockoutdetail.setIdStockOut(mediicinestockout.getId());
 |  |             mediicinestockoutdetail.setIdStockOut(mediicinestockout.getId());
 | 
												
													
														
															|  |             mediicinestockoutdetail.setDrugCode(mediicinedrugs.getDrugCode());
 |  |             mediicinestockoutdetail.setDrugCode(mediicinedrugs.getDrugCode());
 | 
												
													
														
															|  |             mediicinestockoutdetail.setDrudId(mediicinedrugs.getId());
 |  | 
 | 
												
													
														
															|  | 
 |  |             mediicinestockoutdetail.setDrugId(mediicinedrugs.getId());
 | 
												
													
														
															|  |             mediicinestockoutdetail.setOrgCode(mediicinedrugs.getOrgCode());
 |  |             mediicinestockoutdetail.setOrgCode(mediicinedrugs.getOrgCode());
 | 
												
													
														
															|  |             mediicinestockoutdetail.setQuantity(drug.getQty().toString());
 |  |             mediicinestockoutdetail.setQuantity(drug.getQty().toString());
 | 
												
													
														
															|  |             mediicinestockoutdetail.setProductPic(mediicinedrugs.getPic());
 |  |             mediicinestockoutdetail.setProductPic(mediicinedrugs.getPic());
 | 
												
											
												
													
														
															|  | @ -113,7 +118,7 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         result.put("response",ConstantUtils.SUCCESS);
 |  |         result.put("response",ConstantUtils.SUCCESS);
 | 
												
													
														
															|  |         result.put("msg",ConstantUtils.SUCCESS);
 |  |         result.put("msg",ConstantUtils.SUCCESS);
 | 
												
													
														
															|  |         return result.toJSONString();
 |  | 
 | 
												
													
														
															|  | 
 |  |         return result;
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /**
 |  |     /**
 | 
												
											
												
													
														
															|  | @ -262,14 +267,14 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
 | 
												
													
														
															|  |         RoleDO role = roleDao.findOne(user.getRoleId());
 |  |         RoleDO role = roleDao.findOne(user.getRoleId());
 | 
												
													
														
															|  |         String conditionSql = "";
 |  |         String conditionSql = "";
 | 
												
													
														
															|  |         if ("replenisher".equals(role.getCode())) {
 |  |         if ("replenisher".equals(role.getCode())) {
 | 
												
													
														
															|  |             conditionSql += " AND t.replenish_equ = '" + userId + "'\n";
 |  | 
 | 
												
													
														
															|  | 
 |  |             conditionSql += " AND t.replenish_er = '" + userId + "'\n";
 | 
												
													
														
															|  |         } else {
 |  |         } else {
 | 
												
													
														
															|  |             String belongCommunitys = "";
 |  |             String belongCommunitys = "";
 | 
												
													
														
															|  |             String sql = "";
 |  |             String sql = "";
 | 
												
													
														
															|  |             //市管理员
 |  |             //市管理员
 | 
												
													
														
															|  |             if ("saasAdmin".equals(role.getCode())) {
 |  |             if ("saasAdmin".equals(role.getCode())) {
 | 
												
													
														
															|  |                 sql = "SELECT\n" +
 |  |                 sql = "SELECT\n" +
 | 
												
													
														
															|  |                         "\tcode\tas community\n" +
 |  | 
 | 
												
													
														
															|  | 
 |  |                         "\t`code`\tas community\n" +
 | 
												
													
														
															|  |                         "FROM\n" +
 |  |                         "FROM\n" +
 | 
												
													
														
															|  |                         "\tdm_hospital\n" +
 |  |                         "\tdm_hospital\n" +
 | 
												
													
														
															|  |                         "WHERE\n" +
 |  |                         "WHERE\n" +
 | 
												
											
												
													
														
															|  | @ -323,6 +328,7 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
 | 
												
													
														
															|  |                 "    t.replenish_cate as replenishCate,\n" +
 |  |                 "    t.replenish_cate as replenishCate,\n" +
 | 
												
													
														
															|  |                 "    t.replenish_equ as replenishEqu,\n" +
 |  |                 "    t.replenish_equ as replenishEqu,\n" +
 | 
												
													
														
															|  |                 "    t.replenish_er as replenishEr,\n" +
 |  |                 "    t.replenish_er as replenishEr,\n" +
 | 
												
													
														
															|  | 
 |  |                 "    bu.`name` as replenishErName,\n" +
 | 
												
													
														
															|  |                 "    t.replenish_inventory as replenishInventory,\n" +
 |  |                 "    t.replenish_inventory as replenishInventory,\n" +
 | 
												
													
														
															|  |                 "    t.state as state,\n" +
 |  |                 "    t.state as state,\n" +
 | 
												
													
														
															|  |                 "    t.track_num as trackNum,\n" +
 |  |                 "    t.track_num as trackNum,\n" +
 | 
												
											
												
													
														
															|  | @ -334,7 +340,7 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
 | 
												
													
														
															|  |                 "    t.update_user_name as updateUserName,\n" +
 |  |                 "    t.update_user_name as updateUserName,\n" +
 | 
												
													
														
															|  |                 "    t.up_num as upNum\n" +
 |  |                 "    t.up_num as upNum\n" +
 | 
												
													
														
															|  |                 "FROM\n" +
 |  |                 "FROM\n" +
 | 
												
													
														
															|  |                 "    t_mediicine_stockout AS t where 1=1";
 |  | 
 | 
												
													
														
															|  | 
 |  |                 "    t_mediicine_stockout AS t LEFT JOIN base_user bu ON t.replenish_er = bu.id  where 1=1";
 | 
												
													
														
															|  |         if (org.apache.commons.lang.StringUtils.isNotBlank(startTime)&& org.apache.commons.lang.StringUtils.isNotBlank(endTime)){
 |  |         if (org.apache.commons.lang.StringUtils.isNotBlank(startTime)&& org.apache.commons.lang.StringUtils.isNotBlank(endTime)){
 | 
												
													
														
															|  | //            conditionSql += "  AND  t.prescribe_time BETWEEN to_date('" + startTime +"','yyyy-mm-dd hh24:mi:ss') " +
 |  | //            conditionSql += "  AND  t.prescribe_time BETWEEN to_date('" + startTime +"','yyyy-mm-dd hh24:mi:ss') " +
 | 
												
													
														
															|  | //                    " AND to_date('" + endTime + "','yyyy-mm-dd hh24:mi:ss')";
 |  | //                    " AND to_date('" + endTime + "','yyyy-mm-dd hh24:mi:ss')";
 | 
												
											
												
													
														
															|  | @ -345,7 +351,7 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
 | 
												
													
														
															|  |             conditionSql += " and t.receive_state = '" + receiveState + "'";
 |  |             conditionSql += " and t.receive_state = '" + receiveState + "'";
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (!StringUtils.isEmpty(replenishEr)){
 |  |         if (!StringUtils.isEmpty(replenishEr)){
 | 
												
													
														
															|  |             conditionSql += " and t.replenish_er = '" + replenishEr + "'";
 |  | 
 | 
												
													
														
															|  | 
 |  |             conditionSql += " AND CONCAT(IFNULL(bu.`name`,''),IFNULL(bu.`mobile`,'') LIKE '%" + replenishEr + "%'";
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (!StringUtils.isEmpty(docNum)){
 |  |         if (!StringUtils.isEmpty(docNum)){
 | 
												
													
														
															|  |             conditionSql += " and t.doc_num like '%" + docNum + "%'";
 |  |             conditionSql += " and t.doc_num like '%" + docNum + "%'";
 |