|
@@ -1,10 +1,22 @@
|
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.plugins.Page;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.winsea.svc.base.security.util.AuthSecurityUtils;
|
|
|
+import com.yh.saas.common.support.util.IdGenerator;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.MaterialWarehouseInOut;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.MaterialWarehouseInOutMapper;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IMaterialWarehouseInOutService;
|
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -17,4 +29,180 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class MaterialWarehouseInOutServiceImpl extends ServiceImpl<MaterialWarehouseInOutMapper, MaterialWarehouseInOut> implements IMaterialWarehouseInOutService {
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询业务编号
|
|
|
+ * @param materialWarehouseInOut
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<MaterialWarehouseInOut> selectMaterialNoList(MaterialWarehouseInOut materialWarehouseInOut) {
|
|
|
+ SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd");//设置日期格式
|
|
|
+ String date = f.format(new Date(System.currentTimeMillis()));
|
|
|
+ Map<String, Object> pageView = new HashMap<>(7);
|
|
|
+ pageView.put("date", date);
|
|
|
+ pageView.put("warehouseNo", materialWarehouseInOut.getWarehouseNo());
|
|
|
+ pageView.put("inOutFlag", materialWarehouseInOut.getInOutFlag());
|
|
|
+ if("2".equals(materialWarehouseInOut.getInOutFlag())){
|
|
|
+ pageView.put("numberLetter", "WLRK");
|
|
|
+ }else{
|
|
|
+ pageView.put("numberLetter", "WLCK");
|
|
|
+ }
|
|
|
+ pageView.put("compId", materialWarehouseInOut.getCompId());
|
|
|
+ List<MaterialWarehouseInOut> dataList = baseMapper.getListByConditionNo(pageView);
|
|
|
+ return dataList;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ * @param materialWarehouseInOut
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String addMaterial(MaterialWarehouseInOut materialWarehouseInOut) {
|
|
|
+ //新增主键id
|
|
|
+ materialWarehouseInOut.setId(IdGenerator.generateUUID());
|
|
|
+ if(materialWarehouseInOut.getCompId() == null || materialWarehouseInOut.getCompId().isEmpty()){
|
|
|
+ materialWarehouseInOut.setCompId(AuthSecurityUtils.getStaffById(AuthSecurityUtils.getCurrentUserId()).getCompId());
|
|
|
+ }
|
|
|
+ //获取当前年月日
|
|
|
+ SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd");//设置日期格式
|
|
|
+ String date = f.format(new Date(System.currentTimeMillis()));
|
|
|
+ //查询烘干入库信息数量包括已删除的集合
|
|
|
+ List<MaterialWarehouseInOut> materialNoList = this.selectMaterialNoList(materialWarehouseInOut);
|
|
|
+ //生成业务编号
|
|
|
+ if (materialNoList.size() > 0) {
|
|
|
+ //取第一条数据的编号
|
|
|
+ String n = materialNoList.get(0).getBusinessNo();
|
|
|
+ int intNumber = 0;
|
|
|
+ //截取编号后3位
|
|
|
+ intNumber = Integer.parseInt(n.substring(15));
|
|
|
+ intNumber++;
|
|
|
+ String Number = String.valueOf(intNumber);
|
|
|
+ for (int i = 0; i < 3; i++) {
|
|
|
+ Number = Number.length() < 3 ? "0" + Number : Number;
|
|
|
+ }
|
|
|
+ //编号自增
|
|
|
+ //入库编号
|
|
|
+ if("2".equals(materialWarehouseInOut.getInOutFlag())){
|
|
|
+ Number = "WLRK" + date + materialWarehouseInOut.getWarehouseNo() + Number;
|
|
|
+ }
|
|
|
+ //出库编号
|
|
|
+ else{
|
|
|
+ Number = "WLCK" + date + materialWarehouseInOut.getWarehouseNo() + Number;
|
|
|
+ }
|
|
|
+ materialWarehouseInOut.setBusinessNo(Number);
|
|
|
+ } else {
|
|
|
+ //如果当天数据为空,生成第一条数据
|
|
|
+ String Number = "";
|
|
|
+ if("2".equals(materialWarehouseInOut.getInOutFlag())) {
|
|
|
+ Number = "WLRK" + date + materialWarehouseInOut.getWarehouseNo() + "001";
|
|
|
+ }else{
|
|
|
+ Number = "WLCK" + date + materialWarehouseInOut.getWarehouseNo() + "001";
|
|
|
+ }
|
|
|
+ materialWarehouseInOut.setBusinessNo(Number);
|
|
|
+ }
|
|
|
+ //称重
|
|
|
+ if("1".equals(materialWarehouseInOut.getDeliveryMethod())){
|
|
|
+ //称重入库状态更新为待称皮重
|
|
|
+ if ("2".equals(materialWarehouseInOut.getInOutFlag())) {
|
|
|
+ materialWarehouseInOut.setStatus(StatusEnum.MATERIAL_TARE.getName());
|
|
|
+ materialWarehouseInOut.setStatusFlag(StatusEnum.MATERIAL_TARE.getFlag());
|
|
|
+ }
|
|
|
+ //称重出库状态更新为待称毛重
|
|
|
+ else {
|
|
|
+ materialWarehouseInOut.setStatus(StatusEnum.MATERIAL_GROSS.getName());
|
|
|
+ materialWarehouseInOut.setStatusFlag(StatusEnum.MATERIAL_GROSS.getFlag());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //计数
|
|
|
+ else{
|
|
|
+ //计数出库,状态更新为已出库
|
|
|
+ if ("1".equals(materialWarehouseInOut.getInOutFlag())) {
|
|
|
+ materialWarehouseInOut.setStatus(StatusEnum.ALREADY_OUT_MATERIAL.getName());
|
|
|
+ materialWarehouseInOut.setStatusFlag(StatusEnum.ALREADY_OUT_MATERIAL.getFlag());
|
|
|
+ }
|
|
|
+ //计数入库,状态更新为已入库
|
|
|
+ else{
|
|
|
+ materialWarehouseInOut.setStatus(StatusEnum.ALREADY_IN_MATERIAL.getName());
|
|
|
+ materialWarehouseInOut.setStatusFlag(StatusEnum.ALREADY_IN_MATERIAL.getFlag());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ materialWarehouseInOut.setInOutWarehouseDate(new Date());
|
|
|
+ this.insert(materialWarehouseInOut);
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ * @param materialWarehouseInOut
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String editMaterial(MaterialWarehouseInOut materialWarehouseInOut) {
|
|
|
+ //入库,状态更新为已入库
|
|
|
+ if("2".equals(materialWarehouseInOut.getInOutFlag())){
|
|
|
+ materialWarehouseInOut.setStatus(StatusEnum.ALREADY_IN_MATERIAL.getName());
|
|
|
+ materialWarehouseInOut.setStatusFlag(StatusEnum.ALREADY_IN_MATERIAL.getFlag());
|
|
|
+ }
|
|
|
+ //出库,状态更新为已出库
|
|
|
+ else {
|
|
|
+ materialWarehouseInOut.setStatus(StatusEnum.ALREADY_OUT_MATERIAL.getName());
|
|
|
+ materialWarehouseInOut.setStatusFlag(StatusEnum.ALREADY_OUT_MATERIAL.getFlag());
|
|
|
+ }
|
|
|
+ this.updateById(materialWarehouseInOut);
|
|
|
+ return "ok";
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void deleteMaterialInfo(String id) {
|
|
|
+ MaterialWarehouseInOut materialWarehouseInOut = this.selectById(id);
|
|
|
+ if (materialWarehouseInOut != null) {
|
|
|
+ this.deleteById(materialWarehouseInOut.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 物料出入库记录
|
|
|
+ * @param materialWarehouseInOut
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Page<MaterialWarehouseInOut> selectMaterialWarehousePage(MaterialWarehouseInOut materialWarehouseInOut) {
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
+ pageView.put("startRecord", (materialWarehouseInOut.getCurrentPage() - 1)
|
|
|
+ * materialWarehouseInOut.getPageSize());
|
|
|
+ //公司id
|
|
|
+ pageView.put("baseId", materialWarehouseInOut.getBaseId());
|
|
|
+ pageView.put("startDate", materialWarehouseInOut.getStartDate());
|
|
|
+ pageView.put("endDate", materialWarehouseInOut.getEndDate());
|
|
|
+ pageView.put("searchType", materialWarehouseInOut.getSearchType());
|
|
|
+ pageView.put("inOutFlag", materialWarehouseInOut.getInOutFlag());
|
|
|
+ pageView.put("searchKeyWord", materialWarehouseInOut.getSearchKeyWord());
|
|
|
+ pageView.put("pageSize", materialWarehouseInOut.getPageSize());
|
|
|
+ pageView.put("currentPage", materialWarehouseInOut.getCurrentPage());
|
|
|
+ // 查询记录总数
|
|
|
+ Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
+ List<MaterialWarehouseInOut> dataList = baseMapper.getListByCondition(pageView);
|
|
|
+ Page<MaterialWarehouseInOut> page = new Page<>();
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
+ page.setCurrent(materialWarehouseInOut.getCurrentPage());
|
|
|
+ page.setSize(materialWarehouseInOut.getPageSize());
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public MaterialWarehouseInOut getMaterialInfo(String id) {
|
|
|
+ MaterialWarehouseInOut materialWarehouseInOut = this.selectById(id);
|
|
|
+ return materialWarehouseInOut;
|
|
|
+ }
|
|
|
}
|