|
|
@ -13,19 +13,32 @@ import com.win.module.wms.controller.countPlan.vo.CountPlanMainCreateReqVO; |
|
|
|
import com.win.module.wms.controller.countPlan.vo.CountPlanMainExportReqVO; |
|
|
|
import com.win.module.wms.controller.countPlan.vo.CountPlanMainPageReqVO; |
|
|
|
import com.win.module.wms.controller.countPlan.vo.CountPlanMainUpdateReqVO; |
|
|
|
import com.win.module.wms.controller.countRequest.vo.CountRequestDetailCreateReqVO; |
|
|
|
import com.win.module.wms.controller.countRequest.vo.CountRequestMainCreateReqVO; |
|
|
|
import com.win.module.wms.convert.countPlan.CountPlanDetailConvert; |
|
|
|
import com.win.module.wms.convert.countPlan.CountPlanMainConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.balance.BalanceDO; |
|
|
|
import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; |
|
|
|
import com.win.module.wms.dal.dataobject.countPlan.CountPlanDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.countPlan.CountPlanMainDO; |
|
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
|
import com.win.module.wms.dal.mysql.balance.BalanceMapper; |
|
|
|
import com.win.module.wms.dal.mysql.countPlan.CountPlanDetailMapper; |
|
|
|
import com.win.module.wms.dal.mysql.countPlan.CountPlanMainMapper; |
|
|
|
import com.win.module.wms.dal.mysql.countRequest.CountRequestMainMapper; |
|
|
|
import com.win.module.wms.enums.plan.PlanStatusState; |
|
|
|
import com.win.module.wms.service.countRequest.CountRequestMainService; |
|
|
|
import com.win.module.wms.service.itembasic.ItembasicService; |
|
|
|
import com.win.module.wms.util.JobUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
@ -50,12 +63,20 @@ public class CountPlanMainServiceImpl implements CountPlanMainService { |
|
|
|
private TrendsApi trendsApi; |
|
|
|
@Resource |
|
|
|
private SerialNumberApi serialNumberApi; |
|
|
|
@Resource |
|
|
|
private JobUtils jobUtils; |
|
|
|
@Resource |
|
|
|
private BalanceMapper balanceMapper; |
|
|
|
@Resource |
|
|
|
private ItembasicService itembasicService; |
|
|
|
@Resource |
|
|
|
private CountRequestMainService countRequestMainService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Long createCountPlanMain(CountPlanMainCreateReqVO createReqVO) { |
|
|
|
// 插入
|
|
|
|
CountPlanMainDO countPlanMain = CountPlanMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_RECEIPT_REQUEST.getCode()); |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.COUNT_PLAN.getCode()); |
|
|
|
countPlanMain.setNumber(number); |
|
|
|
countPlanMainMapper.insert(countPlanMain); |
|
|
|
List<CountPlanDetailDO> subDOList = CountPlanDetailConvert.INSTANCE.convertList03(createReqVO.getSubList()); |
|
|
@ -225,19 +246,19 @@ public class CountPlanMainServiceImpl implements CountPlanMainService { |
|
|
|
return countPlanMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Integer publishCountPlanMain(Long id) { |
|
|
|
// 校验存在存在下级单据
|
|
|
|
CountPlanMainDO mainDO = validateCountPlanMainExists(id); |
|
|
|
PlanStatusState planStatusState = new PlanStatusState(mainDO.getStatus()); |
|
|
|
boolean flag = planStatusState.execute(); |
|
|
|
boolean flag = planStatusState.publish(); |
|
|
|
if(!flag) { |
|
|
|
throw new ServiceException(COUNT_PLAN_CANNOT_PUBLISH); |
|
|
|
} |
|
|
|
mainDO.setStatus(planStatusState.getState().getCode());//增加操作记录
|
|
|
|
trendsApi.createTrends(id, "countPlan", "发布了盘点计划", TrendsTypeEnum.UPDATE); |
|
|
|
this.generateRequest(mainDO); |
|
|
|
return countPlanMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
@ -256,4 +277,85 @@ public class CountPlanMainServiceImpl implements CountPlanMainService { |
|
|
|
return countPlanMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成盘点申请 |
|
|
|
* @param mainDO 盘点申请主 |
|
|
|
*/ |
|
|
|
private void generateRequest(CountPlanMainDO mainDO) { |
|
|
|
List<CountPlanDetailDO> detailDOList = countPlanDetailMapper.selectList(mainDO.getId()); |
|
|
|
List<BalanceDO> balanceDOList = this.getBalanceDOList(detailDOList); |
|
|
|
CountRequestMainCreateReqVO countRequestMainCreateReqVO = new CountRequestMainCreateReqVO(); |
|
|
|
countRequestMainCreateReqVO.setPlanNumber(mainDO.getNumber()); |
|
|
|
countRequestMainCreateReqVO.setStage("INITIAL_COUNT");//初盘
|
|
|
|
countRequestMainCreateReqVO.setWarehouseCode(""); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("CountRequest"); |
|
|
|
countRequestMainCreateReqVO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
countRequestMainCreateReqVO.setRequestTime(LocalDateTime.now()); |
|
|
|
countRequestMainCreateReqVO.setDueTime(LocalDateTime.now()); |
|
|
|
List<CountRequestDetailCreateReqVO> subList = new ArrayList<>(); |
|
|
|
for(BalanceDO balanceDO : balanceDOList) { |
|
|
|
CountRequestDetailCreateReqVO countRequestDetailCreateReqVO = new CountRequestDetailCreateReqVO(); |
|
|
|
BeanUtils.copyProperties(balanceDO, countRequestDetailCreateReqVO); |
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(balanceDO.getItemCode()); |
|
|
|
countRequestDetailCreateReqVO.setItemName(itembasicDO.getName()); |
|
|
|
countRequestDetailCreateReqVO.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
countRequestDetailCreateReqVO.setItemDesc2(itembasicDO.getDesc2()); |
|
|
|
subList.add(countRequestDetailCreateReqVO); |
|
|
|
} |
|
|
|
countRequestMainCreateReqVO.setSubList(subList); |
|
|
|
countRequestMainService.createCountRequestMain(countRequestMainCreateReqVO); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据盘点计划范围获取库存余额 |
|
|
|
* @param detailDOList 盘点计划范围 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<BalanceDO> getBalanceDOList(List<CountPlanDetailDO> detailDOList) { |
|
|
|
QueryWrapper<BalanceDO> queryWrapper = new QueryWrapper<>(); |
|
|
|
//组装库存余额查询条件
|
|
|
|
for(CountPlanDetailDO countPlanDetailDO : detailDOList) { |
|
|
|
List<String> paramList = new ArrayList<>(Arrays.asList(countPlanDetailDO.getValue().split(","))); |
|
|
|
String inParams = "'" + countPlanDetailDO.getValue() + "'"; |
|
|
|
inParams = inParams.replace(",", "','"); |
|
|
|
switch (countPlanDetailDO.getType()) { |
|
|
|
case "LOCATION_CODE" ://库位编码
|
|
|
|
queryWrapper.in("location_code", paramList); |
|
|
|
break; |
|
|
|
case "LOCATIONGROUP_CODE" : |
|
|
|
queryWrapper.in("location_group_code", paramList); |
|
|
|
break; |
|
|
|
case "AREABASIC_CODE" : |
|
|
|
queryWrapper.in("area_code", paramList); |
|
|
|
break; |
|
|
|
case "WAREHOUSE_CODE" : |
|
|
|
queryWrapper.in("warehouse_code", paramList); |
|
|
|
break; |
|
|
|
case "ITEMS_CODE" : |
|
|
|
queryWrapper.in("item_code", paramList); |
|
|
|
break; |
|
|
|
case "OWNER" : |
|
|
|
queryWrapper.in("owner_code", paramList); |
|
|
|
break; |
|
|
|
case "PROJECT" : |
|
|
|
queryWrapper.inSql("item_code", "SELECT `code` FROM basic_itembasic WHERE project IN(" + inParams + ") AND available='TRUE'"); |
|
|
|
break; |
|
|
|
case "ITEMS_GROUP" : |
|
|
|
queryWrapper.inSql("item_code", "SELECT `code` FROM basic_itembasic WHERE item_group IN(" + inParams + ") AND available='TRUE'"); |
|
|
|
break; |
|
|
|
case "ITEMS_TYPE" : |
|
|
|
queryWrapper.inSql("item_code", "SELECT `code` FROM basic_itembasic WHERE `type` IN(" + inParams + ") AND available='TRUE'"); |
|
|
|
break; |
|
|
|
case "ABC" : |
|
|
|
queryWrapper.inSql("item_code", "SELECT `code` FROM basic_itembasic WHERE abc_class IN(" + inParams + ") AND available='TRUE'"); |
|
|
|
break; |
|
|
|
case "SUPPLIER" : |
|
|
|
queryWrapper.inSql("item_code", "SELECT item_code FROM basic_supplieritem WHERE supplier_code IN(" + inParams + ") AND available='TRUE'"); |
|
|
|
break; |
|
|
|
case "CUSTOMER" : |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
return balanceMapper.selectList(queryWrapper); |
|
|
|
} |
|
|
|
} |
|
|
|