|
@@ -87,6 +87,7 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
|
|
|
public List<YpOutDetlVo> queryYpOutDetlDetail(YpOutDetl ypOutDetl) {
|
|
public List<YpOutDetlVo> queryYpOutDetlDetail(YpOutDetl ypOutDetl) {
|
|
|
return ypOutDetlMapper.selectYpOutDetlDetail(ypOutDetl);
|
|
return ypOutDetlMapper.selectYpOutDetlDetail(ypOutDetl);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<YpOutDetlVo> queryYpOutDetlGroup(YpOutDetl ypOutDetl) {
|
|
public List<YpOutDetlVo> queryYpOutDetlGroup(YpOutDetl ypOutDetl) {
|
|
|
return ypOutDetlMapper.selectYpOutDetlGroup(ypOutDetl);
|
|
return ypOutDetlMapper.selectYpOutDetlGroup(ypOutDetl);
|
|
@@ -119,9 +120,6 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
|
|
|
@Override
|
|
@Override
|
|
|
public int saveYpOutDetlList(Map<String, Object> map, String userId) throws MzException {
|
|
public int saveYpOutDetlList(Map<String, Object> map, String userId) throws MzException {
|
|
|
List<Map<String, Object>> list = (List) map.get("list");
|
|
List<Map<String, Object>> list = (List) map.get("list");
|
|
|
- if(StringUtils.isNotBlank(list.get(0).get("drawNo").toString())){
|
|
|
|
|
- ypOutDetlMapper.deleteByDrawYf(list.get(0).get("drawNo").toString());
|
|
|
|
|
- }
|
|
|
|
|
Map<String, Object> nmap = new HashMap<>();//各药品出库数量合计
|
|
Map<String, Object> nmap = new HashMap<>();//各药品出库数量合计
|
|
|
Map<String, List<Map<String, Object>>> glist = list.stream().collect(Collectors.groupingBy(e -> e.get("chargeCode").toString()));
|
|
Map<String, List<Map<String, Object>>> glist = list.stream().collect(Collectors.groupingBy(e -> e.get("chargeCode").toString()));
|
|
|
glist.forEach((k, slist) -> {
|
|
glist.forEach((k, slist) -> {
|
|
@@ -129,86 +127,10 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
|
|
|
StringUtils.isBlank(e.get("amountOut").toString()) ? 0 : Double.parseDouble(e.get("amountOut").toString())));
|
|
StringUtils.isBlank(e.get("amountOut").toString()) ? 0 : Double.parseDouble(e.get("amountOut").toString())));
|
|
|
nmap.put(slist.get(0).get("chargeCode").toString(), sumcc.getSum());
|
|
nmap.put(slist.get(0).get("chargeCode").toString(), sumcc.getSum());
|
|
|
});
|
|
});
|
|
|
- Integer ykOutNo = ypConfigService.getNo("yk_out_no");
|
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
|
|
|
|
|
- String str = "";
|
|
|
|
|
- if (ykOutNo < 100) {
|
|
|
|
|
- str = "00";
|
|
|
|
|
- } else if (ykOutNo < 1000) {
|
|
|
|
|
- str = "0";
|
|
|
|
|
- }
|
|
|
|
|
- String drawNo = sdf.format(new Date()) + str + ykOutNo;
|
|
|
|
|
- int j = 1;
|
|
|
|
|
-
|
|
|
|
|
- Date now = new Date();
|
|
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
- Map m = list.get(i);
|
|
|
|
|
- String chargeCode = m.get("chargeCode").toString();
|
|
|
|
|
- String serial = m.get("serial").toString();
|
|
|
|
|
- if (!(i > 0 && chargeCode.equals(list.get(i - 1).get("chargeCode").toString())
|
|
|
|
|
- && StringUtils.isBlank(m.get("drawNo").toString())) && StringUtils.isNotBlank(m.get("drawNo").toString())) {
|
|
|
|
|
- YpInPlan ypInPlan = new YpInPlan();
|
|
|
|
|
- ypInPlan.setStatusFlag("2");
|
|
|
|
|
- ypInPlan.setChargeCode(chargeCode);
|
|
|
|
|
- ypInPlan.setSerial(serial);
|
|
|
|
|
- ypInPlan.setDrawNo(m.get("drawNo").toString());
|
|
|
|
|
- ypInPlan.setAmountOut(Double.parseDouble(nmap.get(ypInPlan.getChargeCode()).toString()));
|
|
|
|
|
- int num = ypInPlanMapper.updateYpInPlan(ypInPlan);
|
|
|
|
|
- if (num <= 0) {
|
|
|
|
|
- throw new MzException("更新请领单记录异常!");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (m.get("amountOut") != null && StringUtils.isNotBlank(m.get("amountOut").toString())) {
|
|
|
|
|
- YpOutDetl ypOutDetl = new YpOutDetl();
|
|
|
|
|
- ypOutDetl.setOutDate(now);
|
|
|
|
|
- ypOutDetl.setOutSeri(j++);
|
|
|
|
|
- ypOutDetl.setInDrawNo((String) m.get("inDocuNo"));
|
|
|
|
|
- ypOutDetl.setInSeri(Integer.parseInt(m.get("inSeri").toString()));
|
|
|
|
|
- ypOutDetl.setManuNo((String) m.get("manuNo"));
|
|
|
|
|
- ypOutDetl.setDrawNo(drawNo);
|
|
|
|
|
- if(StringUtils.isNotBlank(m.get("drawNo").toString())){
|
|
|
|
|
- YpInPlan inPlan = new YpInPlan();
|
|
|
|
|
- inPlan.setChargeCode((String) m.get("chargeCode"));
|
|
|
|
|
- inPlan.setSerial((String) m.get("serial"));
|
|
|
|
|
- inPlan.setDrawNo(m.get("drawNo").toString());
|
|
|
|
|
- YpInPlanDrugVo ypInPlanDrugVo = ypInPlanMapper.selectYpInPlanDrug(inPlan).get(0);
|
|
|
|
|
- ypOutDetl.setDrawer(ypInPlanDrugVo.getDrawer());
|
|
|
|
|
- ypOutDetl.setGroupNo(ypInPlanDrugVo.getGroupYk());
|
|
|
|
|
- ypOutDetl.setGroupNoOut(ypInPlanDrugVo.getGroupNo());
|
|
|
|
|
- ypOutDetl.setDrawYf(m.get("drawNo").toString());
|
|
|
|
|
- }else{
|
|
|
|
|
- ypOutDetl.setGroupNo(map.get("groupNo").toString());
|
|
|
|
|
- ypOutDetl.setDrawer(userId);
|
|
|
|
|
- YpZdGroupName ypZdGroupName = new YpZdGroupName();
|
|
|
|
|
- ypZdGroupName.setDeptCode(map.get("deptCode").toString());
|
|
|
|
|
- List<YpZdGroupName> ypZdGroupNames = ypZdGroupNameMapper.selectYpZdGroupNameList(ypZdGroupName);
|
|
|
|
|
- ypOutDetl.setGroupNoOut(ypZdGroupNames.size()>0?ypZdGroupNames.get(0).getGroupNo():null);
|
|
|
|
|
- }
|
|
|
|
|
- ypOutDetl.setDeptCode(map.get("deptCode").toString());
|
|
|
|
|
- ypOutDetl.setChargeCode(chargeCode);
|
|
|
|
|
- ypOutDetl.setSerial(serial);
|
|
|
|
|
- YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(chargeCode, serial);
|
|
|
|
|
- ypOutDetl.setPackRetprice(ypZdDict.getPackRetprice());
|
|
|
|
|
- ypOutDetl.setOutAmt(StringUtils.isBlank(m.get("amountOut").toString()) ? 0 : Double.parseDouble(m.get("amountOut").toString()));
|
|
|
|
|
- ypOutDetl.setKeeper(userId);
|
|
|
|
|
- if(StringUtils.isNotBlank((String) m.get("effDate"))){
|
|
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
- try {
|
|
|
|
|
- ypOutDetl.setEffDate(format.parse((String) m.get("effDate")));
|
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
|
- throw new MzException("有效期转换异常!");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- ypOutDetl.setOutType((String) map.get("outType"));
|
|
|
|
|
- Double stockAmount = ypBaseMapper.selectStockAmount(ypOutDetl.getChargeCode(), ypOutDetl.getSerial(), ypOutDetl.getGroupNo());
|
|
|
|
|
- ypOutDetl.setStockAmount(Double.parseDouble(String.format("%.2f", stockAmount - ypOutDetl.getOutAmt())));
|
|
|
|
|
- ypOutDetl.setBuyPrice(ypZdDict.getBuyPrice());
|
|
|
|
|
- ypOutDetl.setInputId(userId);
|
|
|
|
|
- ypOutDetl.setSysDate(now);
|
|
|
|
|
- ypOutDetl.setAlloPrice(new BigDecimal(0));
|
|
|
|
|
- ypOutDetl.setConfirmFlag("0");
|
|
|
|
|
- ypOutDetlMapper.insertYpOutDetl(ypOutDetl);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (map.get("editFlag").toString().equals("1")) {//修改
|
|
|
|
|
+ editYpOutDetlList(map, nmap);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ newYpOutDetlList(map, nmap, userId);
|
|
|
}
|
|
}
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -224,7 +146,7 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
|
|
|
} else if (ykOutNo < 1000) {
|
|
} else if (ykOutNo < 1000) {
|
|
|
str = "0";
|
|
str = "0";
|
|
|
}
|
|
}
|
|
|
- String drawNo = "T"+sdf.format(new Date()) + str + ykOutNo;
|
|
|
|
|
|
|
+ String drawNo = "T" + sdf.format(new Date()) + str + ykOutNo;
|
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
Map map = list.get(i);
|
|
Map map = list.get(i);
|
|
@@ -238,18 +160,18 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
|
|
|
ypInDetl.setCurrentStock(newOutAmt);
|
|
ypInDetl.setCurrentStock(newOutAmt);
|
|
|
ypInDetl.setInSeri(Integer.parseInt(map.get("inSeri").toString()));
|
|
ypInDetl.setInSeri(Integer.parseInt(map.get("inSeri").toString()));
|
|
|
ypInDetl.setInDocuNo(map.get("inDrawNo").toString());
|
|
ypInDetl.setInDocuNo(map.get("inDrawNo").toString());
|
|
|
- if(ypOutDetlMapper.updateYpOutDetl(ypOutDetl) != 1){
|
|
|
|
|
|
|
+ if (ypOutDetlMapper.updateYpOutDetl(ypOutDetl) != 1) {
|
|
|
throw new MzException("更新历史出库单异常!");
|
|
throw new MzException("更新历史出库单异常!");
|
|
|
}
|
|
}
|
|
|
- if(ypInDetlMapper.updateYpInDetl(ypInDetl) != 1){
|
|
|
|
|
|
|
+ if (ypInDetlMapper.updateYpInDetl(ypInDetl) != 1) {
|
|
|
throw new MzException("更新历史入库单异常!");
|
|
throw new MzException("更新历史入库单异常!");
|
|
|
}
|
|
}
|
|
|
Double stockAmount = ypBaseMapper.selectStockAmount(ypOutDetlVo.getChargeCode(), ypOutDetlVo.getSerial(), ypOutDetlVo.getGroupNo());
|
|
Double stockAmount = ypBaseMapper.selectStockAmount(ypOutDetlVo.getChargeCode(), ypOutDetlVo.getSerial(), ypOutDetlVo.getGroupNo());
|
|
|
YpOutDetl insertYpOutDetl = new YpOutDetl();
|
|
YpOutDetl insertYpOutDetl = new YpOutDetl();
|
|
|
- BeanUtils.copyProperties(ypOutDetlVo,insertYpOutDetl);
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(ypOutDetlVo, insertYpOutDetl);
|
|
|
insertYpOutDetl.setOutDate(date);
|
|
insertYpOutDetl.setOutDate(date);
|
|
|
- insertYpOutDetl.setOutSeri(i+1);
|
|
|
|
|
- insertYpOutDetl.setDrawYf("T"+ypOutDetlVo.getDrawNo());
|
|
|
|
|
|
|
+ insertYpOutDetl.setOutSeri(i + 1);
|
|
|
|
|
+ insertYpOutDetl.setDrawYf("T" + ypOutDetlVo.getDrawNo());
|
|
|
insertYpOutDetl.setDrawNo(drawNo);
|
|
insertYpOutDetl.setDrawNo(drawNo);
|
|
|
insertYpOutDetl.setKeeper(userId);
|
|
insertYpOutDetl.setKeeper(userId);
|
|
|
insertYpOutDetl.setOutType("2");
|
|
insertYpOutDetl.setOutType("2");
|
|
@@ -262,11 +184,11 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
|
|
|
insertYpOutDetl.setConfirmDate(date);
|
|
insertYpOutDetl.setConfirmDate(date);
|
|
|
insertYpOutDetl.setConfirmId(userId);
|
|
insertYpOutDetl.setConfirmId(userId);
|
|
|
insertYpOutDetl.setOutAmt(-newOutAmt);
|
|
insertYpOutDetl.setOutAmt(-newOutAmt);
|
|
|
- if(ypOutDetlMapper.insertYpOutDetl(insertYpOutDetl) == 0){
|
|
|
|
|
|
|
+ if (ypOutDetlMapper.insertYpOutDetl(insertYpOutDetl) == 0) {
|
|
|
throw new MzException("新增出库记录异常!");
|
|
throw new MzException("新增出库记录异常!");
|
|
|
}
|
|
}
|
|
|
- if(ypBaseMapper.updateYpBaseStock(newOutAmt,newOutAmt*Double.parseDouble(map.get("packRetprice").toString()),
|
|
|
|
|
- insertYpOutDetl.getChargeCode(),insertYpOutDetl.getSerial(),insertYpOutDetl.getGroupNo()) != 1){
|
|
|
|
|
|
|
+ if (ypBaseMapper.updateYpBaseStock(newOutAmt, newOutAmt * Double.parseDouble(map.get("packRetprice").toString()),
|
|
|
|
|
+ insertYpOutDetl.getChargeCode(), insertYpOutDetl.getSerial(), insertYpOutDetl.getGroupNo()) != 1) {
|
|
|
throw new MzException("更新库存异常!");
|
|
throw new MzException("更新库存异常!");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -301,7 +223,7 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
|
|
|
ypOutDetl.setConfirmDate(now);
|
|
ypOutDetl.setConfirmDate(now);
|
|
|
ypOutDetl.setDrawNo(ypOutDetlVo.getDrawNo());
|
|
ypOutDetl.setDrawNo(ypOutDetlVo.getDrawNo());
|
|
|
ypOutDetlMapper.updateYpOutDetl(ypOutDetl);
|
|
ypOutDetlMapper.updateYpOutDetl(ypOutDetl);
|
|
|
- if(StringUtils.isNotBlank(ypOutDetlVo.getDrawYf())){
|
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(ypOutDetlVo.getDrawYf())) {
|
|
|
YpInPlan ypInPlan = new YpInPlan();
|
|
YpInPlan ypInPlan = new YpInPlan();
|
|
|
ypInPlan.setConfirmId(userId);
|
|
ypInPlan.setConfirmId(userId);
|
|
|
ypInPlan.setConfirmDate(now);
|
|
ypInPlan.setConfirmDate(now);
|
|
@@ -315,12 +237,12 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<YpOutDetlVo> queryYpOutDetlDrugReturnPage(YpOutDetl ypOutDetl) {
|
|
public List<YpOutDetlVo> queryYpOutDetlDrugReturnPage(YpOutDetl ypOutDetl) {
|
|
|
- List<YpOutDetlVo> ypOutDetlVos= new ArrayList<>();
|
|
|
|
|
|
|
+ List<YpOutDetlVo> ypOutDetlVos = new ArrayList<>();
|
|
|
List<YpOutDetl> ypOutDetls = ypOutDetlMapper.selectYpOutDetlDrugReturnPage(ypOutDetl);
|
|
List<YpOutDetl> ypOutDetls = ypOutDetlMapper.selectYpOutDetlDrugReturnPage(ypOutDetl);
|
|
|
for (int i = 0; i < ypOutDetls.size(); i++) {
|
|
for (int i = 0; i < ypOutDetls.size(); i++) {
|
|
|
YpOutDetl yp = ypOutDetls.get(i);
|
|
YpOutDetl yp = ypOutDetls.get(i);
|
|
|
YpOutDetlVo ypOutDetlVo = new YpOutDetlVo();
|
|
YpOutDetlVo ypOutDetlVo = new YpOutDetlVo();
|
|
|
- BeanUtils.copyProperties(yp,ypOutDetlVo);
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(yp, ypOutDetlVo);
|
|
|
YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(yp.getChargeCode(), yp.getSerial());
|
|
YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(yp.getChargeCode(), yp.getSerial());
|
|
|
ypOutDetlVo.setName(ypZdDict.getName());
|
|
ypOutDetlVo.setName(ypZdDict.getName());
|
|
|
ypOutDetlVo.setSpecification(ypZdDict.getSpecification());
|
|
ypOutDetlVo.setSpecification(ypZdDict.getSpecification());
|
|
@@ -333,7 +255,7 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
|
|
|
String supplyName = ypZdSupplyMapper.selectNameByCode(ypInDetls.get(0).getSupplyCode());
|
|
String supplyName = ypZdSupplyMapper.selectNameByCode(ypInDetls.get(0).getSupplyCode());
|
|
|
ypOutDetlVo.setSupplyName(supplyName);
|
|
ypOutDetlVo.setSupplyName(supplyName);
|
|
|
ypOutDetlVo.setKeeperName(employeeMapper.selectByUserCode(yp.getKeeper()).getEmployeeName());
|
|
ypOutDetlVo.setKeeperName(employeeMapper.selectByUserCode(yp.getKeeper()).getEmployeeName());
|
|
|
- if(StringUtils.isNotBlank(yp.getGroupNoOut())){
|
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(yp.getGroupNoOut())) {
|
|
|
ypOutDetlVo.setGroupNoOutName(ypZdGroupNameMapper.selectByGroupNo(yp.getGroupNoOut()).getGroupName());
|
|
ypOutDetlVo.setGroupNoOutName(ypZdGroupNameMapper.selectByGroupNo(yp.getGroupNoOut()).getGroupName());
|
|
|
}
|
|
}
|
|
|
ypOutDetlVo.setOutType(OutTypeEnum.getOutTypeByCode(yp.getOutType()).name);
|
|
ypOutDetlVo.setOutType(OutTypeEnum.getOutTypeByCode(yp.getOutType()).name);
|
|
@@ -353,11 +275,139 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
Map<String, Object> stringObjectMap = list.get(i);
|
|
Map<String, Object> stringObjectMap = list.get(i);
|
|
|
YpZdDrugKind drugKind = ypZdDrugKindMapper.selectYpZdDrugKind(stringObjectMap.get("drugKind").toString());
|
|
YpZdDrugKind drugKind = ypZdDrugKindMapper.selectYpZdDrugKind(stringObjectMap.get("drugKind").toString());
|
|
|
- stringObjectMap.put("kindName",drugKind.getName());
|
|
|
|
|
- stringObjectMap.put("ypType",drugKind.getYpType());
|
|
|
|
|
|
|
+ stringObjectMap.put("kindName", drugKind.getName());
|
|
|
|
|
+ stringObjectMap.put("ypType", drugKind.getYpType());
|
|
|
ZdUnitCode deptCode = zdUnitCodeMapper.selectByCode(stringObjectMap.get("deptCode").toString());
|
|
ZdUnitCode deptCode = zdUnitCodeMapper.selectByCode(stringObjectMap.get("deptCode").toString());
|
|
|
- stringObjectMap.put("deptName",deptCode.getName());
|
|
|
|
|
|
|
+ stringObjectMap.put("deptName", deptCode.getName());
|
|
|
}
|
|
}
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 编辑出库单
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param map
|
|
|
|
|
+ */
|
|
|
|
|
+ private void editYpOutDetlList(Map<String, Object> map, Map<String, Object> nmap) {
|
|
|
|
|
+ List<Map<String, Object>> list = (List) map.get("list");
|
|
|
|
|
+ YpInPlan ypInPlan = new YpInPlan();
|
|
|
|
|
+ String drawYf = ypOutDetlMapper.selectDrawYf(map.get("drawNo").toString());
|
|
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
+ Map<String, Object> stringObjectMap = list.get(i);
|
|
|
|
|
+ YpOutDetl ypOutDetl = new YpOutDetl();
|
|
|
|
|
+ ypOutDetl.setDrawNo(stringObjectMap.get("drawNo").toString());
|
|
|
|
|
+ ypOutDetl.setInDrawNo(stringObjectMap.get("inDocuNo").toString());
|
|
|
|
|
+ ypOutDetl.setChargeCode(stringObjectMap.get("chargeCode").toString());
|
|
|
|
|
+ ypOutDetl.setSerial(stringObjectMap.get("serial").toString());
|
|
|
|
|
+ ypOutDetl.setInSeri(Integer.parseInt(stringObjectMap.get("inSeri").toString()));
|
|
|
|
|
+ ypOutDetl.setOutAmt(Double.parseDouble(stringObjectMap.get("amountOut").toString()));
|
|
|
|
|
+ ypOutDetlMapper.updateYpOutDetl(ypOutDetl);
|
|
|
|
|
+ if (StringUtils.isNotBlank(drawYf)) {
|
|
|
|
|
+ ypInPlan.setDrawNo(drawYf);
|
|
|
|
|
+ ypInPlan.setChargeCode(ypOutDetl.getChargeCode());
|
|
|
|
|
+ ypInPlan.setSerial(ypOutDetl.getSerial());
|
|
|
|
|
+ ypInPlan.setAmountOut(Double.parseDouble(nmap.get(ypInPlan.getChargeCode()).toString()));
|
|
|
|
|
+ ypInPlanMapper.updateYpInPlan(ypInPlan);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Map<String, Object>> delList = (List) map.get("delList");
|
|
|
|
|
+ for (int i = 0; i < delList.size(); i++) {
|
|
|
|
|
+ Map<String, Object> data = delList.get(i);
|
|
|
|
|
+ ypOutDetlMapper.deleteYpOutDetl(data.get("drawNo").toString(), data.get("chargeCode").toString(), data.get("serial").toString());
|
|
|
|
|
+ ypInPlan.setDrawNo(drawYf);
|
|
|
|
|
+ ypInPlan.setChargeCode(data.get("chargeCode").toString());
|
|
|
|
|
+ ypInPlan.setSerial(data.get("serial").toString());
|
|
|
|
|
+ ypInPlan.setAmountOut(0.0);
|
|
|
|
|
+ ypInPlanMapper.updateYpInPlan(ypInPlan);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增出库单
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param map
|
|
|
|
|
+ */
|
|
|
|
|
+ private void newYpOutDetlList(Map<String, Object> map, Map<String, Object> nmap, String userId) throws MzException {
|
|
|
|
|
+ List<Map<String, Object>> list = (List) map.get("list");
|
|
|
|
|
+ Integer ykOutNo = ypConfigService.getNo("yk_out_no");
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
|
|
|
|
|
+ String str = "";
|
|
|
|
|
+ if (ykOutNo < 100) {
|
|
|
|
|
+ str = "00";
|
|
|
|
|
+ } else if (ykOutNo < 1000) {
|
|
|
|
|
+ str = "0";
|
|
|
|
|
+ }
|
|
|
|
|
+ String drawNo = sdf.format(new Date()) + str + ykOutNo;
|
|
|
|
|
+ int j = 1;
|
|
|
|
|
+ Date now = new Date();
|
|
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
+ Map m = list.get(i);
|
|
|
|
|
+ String chargeCode = m.get("chargeCode").toString();
|
|
|
|
|
+ String serial = m.get("serial").toString();
|
|
|
|
|
+ if (!(i > 0 && chargeCode.equals(list.get(i - 1).get("chargeCode").toString())
|
|
|
|
|
+ && StringUtils.isBlank(m.get("drawNo").toString())) && StringUtils.isNotBlank(m.get("drawNo").toString())) {
|
|
|
|
|
+ YpInPlan ypInPlan = new YpInPlan();
|
|
|
|
|
+ ypInPlan.setStatusFlag("2");
|
|
|
|
|
+ ypInPlan.setChargeCode(chargeCode);
|
|
|
|
|
+ ypInPlan.setSerial(serial);
|
|
|
|
|
+ ypInPlan.setDrawNo(m.get("drawNo").toString());
|
|
|
|
|
+ ypInPlan.setAmountOut(Double.parseDouble(nmap.get(ypInPlan.getChargeCode()).toString()));
|
|
|
|
|
+ int num = ypInPlanMapper.updateYpInPlan(ypInPlan);
|
|
|
|
|
+ if (num <= 0) {
|
|
|
|
|
+ throw new MzException("更新请领单记录异常!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (m.get("amountOut") != null && StringUtils.isNotBlank(m.get("amountOut").toString())) {
|
|
|
|
|
+ YpOutDetl ypOutDetl = new YpOutDetl();
|
|
|
|
|
+ ypOutDetl.setOutDate(now);
|
|
|
|
|
+ ypOutDetl.setOutSeri(j++);
|
|
|
|
|
+ ypOutDetl.setInDrawNo((String) m.get("inDocuNo"));
|
|
|
|
|
+ ypOutDetl.setInSeri(Integer.parseInt(m.get("inSeri").toString()));
|
|
|
|
|
+ ypOutDetl.setManuNo((String) m.get("manuNo"));
|
|
|
|
|
+ ypOutDetl.setDrawNo(drawNo);
|
|
|
|
|
+ if (StringUtils.isNotBlank(m.get("drawNo").toString())) {
|
|
|
|
|
+ YpInPlan inPlan = new YpInPlan();
|
|
|
|
|
+ inPlan.setChargeCode((String) m.get("chargeCode"));
|
|
|
|
|
+ inPlan.setSerial((String) m.get("serial"));
|
|
|
|
|
+ inPlan.setDrawNo(m.get("drawNo").toString());
|
|
|
|
|
+ YpInPlanDrugVo ypInPlanDrugVo = ypInPlanMapper.selectYpInPlanDrug(inPlan).get(0);
|
|
|
|
|
+ ypOutDetl.setDrawer(ypInPlanDrugVo.getDrawer());
|
|
|
|
|
+ ypOutDetl.setGroupNo(ypInPlanDrugVo.getGroupYk());
|
|
|
|
|
+ ypOutDetl.setGroupNoOut(ypInPlanDrugVo.getGroupNo());
|
|
|
|
|
+ ypOutDetl.setDrawYf(m.get("drawNo").toString());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ypOutDetl.setGroupNo(map.get("groupNo").toString());
|
|
|
|
|
+ ypOutDetl.setDrawer(userId);
|
|
|
|
|
+ YpZdGroupName ypZdGroupName = new YpZdGroupName();
|
|
|
|
|
+ ypZdGroupName.setDeptCode(map.get("deptCode").toString());
|
|
|
|
|
+ List<YpZdGroupName> ypZdGroupNames = ypZdGroupNameMapper.selectYpZdGroupNameList(ypZdGroupName);
|
|
|
|
|
+ ypOutDetl.setGroupNoOut(ypZdGroupNames.size() > 0 ? ypZdGroupNames.get(0).getGroupNo() : null);
|
|
|
|
|
+ }
|
|
|
|
|
+ ypOutDetl.setDeptCode(map.get("deptCode").toString());
|
|
|
|
|
+ ypOutDetl.setChargeCode(chargeCode);
|
|
|
|
|
+ ypOutDetl.setSerial(serial);
|
|
|
|
|
+ YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(chargeCode, serial);
|
|
|
|
|
+ ypOutDetl.setPackRetprice(ypZdDict.getPackRetprice());
|
|
|
|
|
+ ypOutDetl.setOutAmt(StringUtils.isBlank(m.get("amountOut").toString()) ? 0 : Double.parseDouble(m.get("amountOut").toString()));
|
|
|
|
|
+ ypOutDetl.setKeeper(userId);
|
|
|
|
|
+ if (StringUtils.isNotBlank((String) m.get("effDate"))) {
|
|
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ try {
|
|
|
|
|
+ ypOutDetl.setEffDate(format.parse((String) m.get("effDate")));
|
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
|
+ throw new MzException("有效期转换异常!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ypOutDetl.setOutType((String) map.get("outType"));
|
|
|
|
|
+ Double stockAmount = ypBaseMapper.selectStockAmount(ypOutDetl.getChargeCode(), ypOutDetl.getSerial(), ypOutDetl.getGroupNo());
|
|
|
|
|
+ ypOutDetl.setStockAmount(Double.parseDouble(String.format("%.2f", stockAmount - ypOutDetl.getOutAmt())));
|
|
|
|
|
+ ypOutDetl.setBuyPrice(ypZdDict.getBuyPrice());
|
|
|
|
|
+ ypOutDetl.setInputId(userId);
|
|
|
|
|
+ ypOutDetl.setSysDate(now);
|
|
|
|
|
+ ypOutDetl.setAlloPrice(new BigDecimal(0));
|
|
|
|
|
+ ypOutDetl.setConfirmFlag("0");
|
|
|
|
|
+ ypOutDetlMapper.insertYpOutDetl(ypOutDetl);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|