|
@ -64,13 +64,13 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String createDetailOut(String jsonData) {
|
|
|
public JSONObject createDetailOut(String jsonData) {
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
if(StringUtils.isEmpty(jsonData)){
|
|
|
result.put("msg","jsonData is null");
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result.toJSONString();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
JSONObject out = JSONObject.parseObject(jsonData);
|
|
@ -79,7 +79,12 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
|
|
|
if (obj == null ) {
|
|
|
result.put("msg", "obj is null!");
|
|
|
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());
|
|
@ -98,14 +103,14 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
|
|
|
mediicinestockout.setState("1");
|
|
|
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);
|
|
|
for (DrugDO drug : obj.getDrugs()) {
|
|
|
Mediicinedrugs mediicinedrugs = drugsDao.findOne(drug.getDrugId());
|
|
|
Mediicinestockoutdetail mediicinestockoutdetail = new Mediicinestockoutdetail();
|
|
|
mediicinestockoutdetail.setIdStockOut(mediicinestockout.getId());
|
|
|
mediicinestockoutdetail.setDrugCode(mediicinedrugs.getDrugCode());
|
|
|
mediicinestockoutdetail.setDrudId(mediicinedrugs.getId());
|
|
|
mediicinestockoutdetail.setDrugId(mediicinedrugs.getId());
|
|
|
mediicinestockoutdetail.setOrgCode(mediicinedrugs.getOrgCode());
|
|
|
mediicinestockoutdetail.setQuantity(drug.getQty().toString());
|
|
|
mediicinestockoutdetail.setProductPic(mediicinedrugs.getPic());
|
|
@ -113,7 +118,7 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
|
|
|
}
|
|
|
result.put("response",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());
|
|
|
String conditionSql = "";
|
|
|
if ("replenisher".equals(role.getCode())) {
|
|
|
conditionSql += " AND t.replenish_equ = '" + userId + "'\n";
|
|
|
conditionSql += " AND t.replenish_er = '" + userId + "'\n";
|
|
|
} else {
|
|
|
String belongCommunitys = "";
|
|
|
String sql = "";
|
|
|
//市管理员
|
|
|
if ("saasAdmin".equals(role.getCode())) {
|
|
|
sql = "SELECT\n" +
|
|
|
"\tcode\tas community\n" +
|
|
|
"\t`code`\tas community\n" +
|
|
|
"FROM\n" +
|
|
|
"\tdm_hospital\n" +
|
|
|
"WHERE\n" +
|
|
@ -323,6 +328,7 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
|
|
|
" t.replenish_cate as replenishCate,\n" +
|
|
|
" t.replenish_equ as replenishEqu,\n" +
|
|
|
" t.replenish_er as replenishEr,\n" +
|
|
|
" bu.`name` as replenishErName,\n" +
|
|
|
" t.replenish_inventory as replenishInventory,\n" +
|
|
|
" t.state as state,\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.up_num as upNum\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)){
|
|
|
// 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')";
|
|
@ -345,7 +351,7 @@ public class MedicineStockOutService extends BaseJpaService<Mediicinestockout, M
|
|
|
conditionSql += " and t.receive_state = '" + receiveState + "'";
|
|
|
}
|
|
|
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)){
|
|
|
conditionSql += " and t.doc_num like '%" + docNum + "%'";
|