1 文件已重命名
6个文件已添加
13个文件已修改
| | |
| | | package com.consum.base.controller; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.core.utils.MapUtils; |
| | |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.web.ResponseValue; |
| | | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * @Description 物品模板 |
| | |
| | | if (StringUtils.isEmpty(param.getGoodsName())) { |
| | | return ResponseValue.error("物品名称为空"); |
| | | } |
| | | //判断同一分类下的物品名称是否重复 |
| | | BaseGoodsTemplate goodsTemplate = this.baseGoodsTemplateService.getByGoodsNameAndCategoryId(param.getGoodsName(), param.getCategoryId()); |
| | | // 判断同一分类下的物品名称是否重复 |
| | | BaseGoodsTemplate goodsTemplate = |
| | | this.baseGoodsTemplateService.getByGoodsNameAndCategoryId(param.getGoodsName(), param.getCategoryId()); |
| | | if (goodsTemplate != null) { |
| | | return ResponseValue.error("物品名称已存在"); |
| | | } |
| | |
| | | * @author 卢庆阳 |
| | | * @date 2023/10/25 |
| | | */ |
| | | //TODO 物品的禁用或删除,不影响已经采购入过库的物品信息。 |
| | | // TODO 物品的禁用或删除,不影响已经采购入过库的物品信息。 |
| | | @PostMapping("/updStatus") |
| | | public ResponseValue updateStatus() { |
| | | BaseGoodsTemplate goodsTemplate = CommonUtil.getObjFromReqBody(BaseGoodsTemplate.class); |
| | |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/25 |
| | | */ |
| | | //TODO 物品的禁用或删除,不影响已经采购入过库的物品信息。 |
| | | // TODO 物品的禁用或删除,不影响已经采购入过库的物品信息。 |
| | | @DeleteMapping("/del") |
| | | public ResponseValue updateById() { |
| | | BaseGoodsTemplate goodsTemplate = CommonUtil.getObjFromReqBody(BaseGoodsTemplate.class); |
| | |
| | | |
| | | @GetMapping("/query/goodsTemplate") |
| | | public ResponseValue queryGoodsTemplateByCategoryId(Long agencyId, Long categoryId) { |
| | | List<BaseGoodsTemplate> list = this.baseGoodsTemplateService.queryGoodsTemplateByCategoryId(agencyId, categoryId, null, null); |
| | | List<BaseGoodsTemplate> list = |
| | | this.baseGoodsTemplateService.queryGoodsTemplateByCategoryId(agencyId, categoryId, null, null); |
| | | if (list == null) { |
| | | return ResponseValue.error("查询失败!"); |
| | | } |
| | | return ResponseValue.success("查询成功!", list); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "查询机构下默认仓库下的分类模板信息", notes = "查询机构下默认仓库下的分类模板信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "agencyId", value = "父级机构id", required = true, dataType = "java.lang.Long", paramType = "query"), |
| | | @ApiImplicitParam(name = "categoryId", value = "分类id", required = true, dataType = "Long", paramType = "query") |
| | | }) |
| | | @ApiImplicitParam(name = "agencyId", value = "父级机构id", required = true, dataType = "java.lang.Long", |
| | | paramType = "query"), |
| | | @ApiImplicitParam(name = "categoryId", value = "分类id", required = true, dataType = "Long", |
| | | paramType = "query")}) |
| | | @GetMapping("/query/warehouse/goods") |
| | | public ResponseValue queryWarehouseGoods(Long agencyId, Long categoryId) { |
| | | |
| | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("categoryId", categoryId); |
| | | |
| | | List<BaseWarehouse> baseWarehouseList = baseWarehouseService.getByAgencyId(agencyId, (short) 1, (short) 1); |
| | | List<BaseWarehouse> baseWarehouseList = baseWarehouseService.getByAgencyId(agencyId, (short)1, (short)1); |
| | | if (CollectionUtils.isEmpty(baseWarehouseList)) { |
| | | return ResponseValue.error("机构无默认仓库!"); |
| | | |
| | |
| | | |
| | | String sql = |
| | | "SELECT DISTINCT bgt.id,bgt.GOODS_NAME, CLASSIFICATION type FROM l_wh_goods g LEFT JOIN base_goods_template bgt ON g.BASE_GOODS_TEMPLATE_ID = bgt.id " |
| | | + "WHERE WAREHOUSE_TYPE = 0 " |
| | | + "AND WAREHOUSE_ID = :warehouseId " |
| | | + "AND CATEGORY_ID = :categoryId " |
| | | + "WHERE WAREHOUSE_TYPE = 0 " + "AND WAREHOUSE_ID = :warehouseId " + "AND CATEGORY_ID = :categoryId " |
| | | // 1:集采,2:自采 |
| | | + "AND BUY_TYPE =1"; |
| | | |
| | |
| | | return ResponseValue.success("查询成功!", resultList); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | package com.consum.base.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.pojo.BaseWarehouseParam; |
| | |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.web.ResponseValue; |
| | | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * @Description 仓库管理 |
| | |
| | | import com.consum.base.pojo.response.GoodsTemplateCountVO; |
| | | import com.consum.base.pojo.response.LWhFormOutputExtendVO; |
| | | import com.consum.base.service.LWarehouseFlowService; |
| | | import com.consum.base.service.LWhFormOutputServiceImpl; |
| | | import com.consum.base.service.LWhFormOutputService; |
| | | import com.consum.base.service.LWhProcureModelService; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhFormOutput; |
| | |
| | | public class LWhFormOutputController extends BaseController { |
| | | |
| | | @Autowired |
| | | private LWhFormOutputServiceImpl lWhFormOutputService; |
| | | private LWhFormOutputService lWhFormOutputService; |
| | | @Autowired |
| | | private LWhProcureModelService lWhProcureModelService; |
| | | @Resource |
| | |
| | | package com.consum.base.controller; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.service.LWhGoodsService; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.web.ResponseValue; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import cn.hutool.core.convert.Convert; |
| | | import io.swagger.annotations.Api; |
| | | |
| | | /** |
| | | * @ClassName LWhHomeStatisticsController |
New file |
| | |
| | | package com.consum.base.core.type; |
| | | |
| | | /** |
| | | * 物品型号业务类型 |
| | | * |
| | | * @author asus |
| | | * @version 2023/12/05 10:40 |
| | | **/ |
| | | public enum GoodsModelType { |
| | | /** |
| | | * 采购 |
| | | */ |
| | | PROCURE(1, "采购"), |
| | | /** |
| | | * 调拨 |
| | | */ |
| | | TRANSFER(2, "调拨"), |
| | | /** |
| | | * 出库 |
| | | */ |
| | | OUT_PUT(3, "出库"), |
| | | /** |
| | | * 部门分发 |
| | | */ |
| | | DEPARTMENT_DISTRIBUTION(4, "部门分发"); |
| | | |
| | | private Integer value; |
| | | |
| | | private String desc; |
| | | |
| | | GoodsModelType(Integer value, String desc) { |
| | | this.value = value; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(Integer value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | public void setDesc(String desc) { |
| | | this.desc = desc; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.consum.base.core.type; |
| | | |
| | | /** |
| | | * 所有物品状态枚举 |
| | | * |
| | | * @author asus |
| | | * @version 2023/12/05 14:01 |
| | | **/ |
| | | public enum GoodsStatesType { |
| | | |
| | | /** |
| | | * 在途调拨 |
| | | */ |
| | | ON_ROAD_TRANSFER(0, "在途调拨"), |
| | | /** |
| | | * 入库未分发 |
| | | */ |
| | | IN_STOCK_UN_DISTRIBUTION(1, "入库未分发"), |
| | | /** |
| | | * 已下发 |
| | | */ |
| | | DISTRIBUTION_DONE(2, "已下发"), |
| | | /** |
| | | * 报废 |
| | | */ |
| | | SCRAP(3, "报废"), |
| | | /** |
| | | * 零星出库 |
| | | */ |
| | | SINGLE_OUT(4, "零星出库"); |
| | | |
| | | private Integer value; |
| | | |
| | | private String desc; |
| | | |
| | | GoodsStatesType(Integer value, String desc) { |
| | | this.value = value; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(Integer value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | public void setDesc(String desc) { |
| | | this.desc = desc; |
| | | } |
| | | } |
New file |
| | |
| | | package com.consum.base.core.type; |
| | | |
| | | /** |
| | | * 盘点单状态枚举 |
| | | * |
| | | * @author asus |
| | | * @version 2023/12/05 10:40 |
| | | **/ |
| | | public enum InventoryStatesType { |
| | | /** |
| | | * 未开始 |
| | | */ |
| | | NEW(0, "未开始"), |
| | | /** |
| | | * 进行中 |
| | | */ |
| | | PENDING(1, "进行中"), |
| | | |
| | | /** |
| | | * 已完成 |
| | | */ |
| | | SUCCESS(2, "已完成"); |
| | | |
| | | private Integer value; |
| | | |
| | | private String desc; |
| | | |
| | | InventoryStatesType(Integer value, String desc) { |
| | | this.value = value; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(Integer value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | public void setDesc(String desc) { |
| | | this.desc = desc; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.consum.base.core.type; |
| | | |
| | | /** |
| | | * 出库单状态枚举 |
| | | * |
| | | * @author asus |
| | | * @version 2023/12/05 10:40 |
| | | **/ |
| | | public enum OutPutStatesType { |
| | | /** |
| | | * 待出库 |
| | | */ |
| | | OUT_PENDING(1, "待出库"), |
| | | |
| | | /** |
| | | * 已出库 |
| | | */ |
| | | OUT_SUCCESS(2, "已出库"); |
| | | |
| | | private Integer value; |
| | | |
| | | private String desc; |
| | | |
| | | OutPutStatesType(Integer value, String desc) { |
| | | this.value = value; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public Integer getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(Integer value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | public void setDesc(String desc) { |
| | | this.desc = desc; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.consum.base.pojo.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author asus |
| | | * @version 1.0 |
| | | * @description: 型号统计 |
| | | * @date 2023/12/5 13:43 |
| | | */ |
| | | @Data |
| | | public class GoodsModelCountDTO { |
| | | |
| | | private Long baseModelId; |
| | | private Integer amount; |
| | | } |
| | |
| | | package com.consum.base.service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import com.consum.base.core.utils.IdUtil; |
| | | import com.consum.base.core.utils.LockManage; |
| | | import com.consum.model.po.LGoodsUserRecord; |
| | | import com.consum.model.po.LWhFormTransfer; |
| | | import com.consum.model.po.LWhProcureModelUser; |
| | | import com.consum.model.po.LWhProcureModelUserRecord; |
| | | import com.walker.infrastructure.utils.NumberGenerator; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @ClassName LGoodsUserRecordCoreService |
| | |
| | | * @return |
| | | */ |
| | | public boolean modifyGoodsUser(Long oldProcureModelUserRecordId, Long newProcureModelUserRecordId) { |
| | | LWhProcureModelUserRecord lWhProcureModelUserRecord = goodsBaseService.get(new LWhProcureModelUserRecord(newProcureModelUserRecordId)); |
| | | LWhProcureModelUserRecord lWhProcureModelUserRecord = |
| | | goodsBaseService.get(new LWhProcureModelUserRecord(newProcureModelUserRecordId)); |
| | | if (lWhProcureModelUserRecord == null) { |
| | | return false; |
| | | } |
| | |
| | | Integer inWarehouseType = whFormTransfer.getInWarehouseType(); |
| | | Long inWarehouseId = whFormTransfer.getInWarehouseId(); |
| | | // 将所有物品设置为未分发 |
| | | List<Long> srappedGoodsIds = lWhGoodsService.queryScrappedGoodsIds(inWarehouseType, inWarehouseId, transBusinessId, null, null, null, null); |
| | | List<Long> srappedGoodsIds = lWhGoodsService.queryScrappedGoodsIds(inWarehouseType, inWarehouseId, |
| | | transBusinessId, null, null, null, null); |
| | | lWhGoodsService.modGoodsTransfering(srappedGoodsIds, null, null, null, 3); |
| | | // 删除该调拨单旧有使用记录 |
| | | lGoodsUserRecordService.delete(new LGoodsUserRecord(), "where TRANS_BUSINESS_ID =" + transBusinessId, new HashMap<>()); |
| | | lGoodsUserRecordService.delete(new LGoodsUserRecord(), "where TRANS_BUSINESS_ID =" + transBusinessId, |
| | | new HashMap<>()); |
| | | // 设置旧的LAST_RECORD= 0 |
| | | lGoodsUserRecordService.updSetNotLast(srappedGoodsIds); |
| | | //插入新的 |
| | | // 插入新的 |
| | | LWhProcureModelUser modelUser = new LWhProcureModelUser(); |
| | | modelUser.setProcureModelUserRecordId(newProcureModelUserRecordId); |
| | | List<LWhProcureModelUser> modelUserList = goodsBaseService.select(modelUser); |
| | |
| | | for (LWhProcureModelUser lWhProcureModelUser : modelUserList) { |
| | | Long baseGoodsModelsId = lWhProcureModelUser.getBaseGoodsModelsId(); |
| | | Integer goodsNum = lWhProcureModelUser.getGoodsNum(); |
| | | //通过LockManage获得锁 |
| | | // 通过LockManage获得锁 |
| | | Object warehouseModelLockObj = LockManage.acquireLock(inWarehouseType, inWarehouseId, baseGoodsModelsId); |
| | | synchronized (warehouseModelLockObj) { |
| | | List<Long> toUserGoodsIds = lWhGoodsService.queryScrappedGoodsIds(inWarehouseType, inWarehouseId, transBusinessId, null, baseGoodsModelsId, |
| | | (short) 1, goodsNum); |
| | | List<Long> toUserGoodsIds = lWhGoodsService.queryScrappedGoodsIds(inWarehouseType, inWarehouseId, |
| | | transBusinessId, null, baseGoodsModelsId, (short)1, goodsNum); |
| | | if (CollectionUtils.isEmpty(toUserGoodsIds)) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | throw new RuntimeException("操作失败!型号数量不足"); |
| | |
| | | return true; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(IdUtil.generateId()); |
| | | System.out.println(NumberGenerator.getLongSequenceNumber() ); |
| | | } |
| | | } |
| | |
| | | private LWhGoodsService lWhGoodsService; |
| | | private LWhFormInventoryService lWhFormInventoryService; |
| | | private LWhFormProcureCoreService lWhFormProcureCoreService; |
| | | private LWhFormOutputServiceImpl lWhFormOutputService; |
| | | private LWhFormOutputService lWhFormOutputService; |
| | | |
| | | @Autowired |
| | | public LWhFormInventoryCoreService(LWhFormInventoryGoodsServiceImpl lWhFormInventoryGoods, |
| | |
| | | LWhGoodsService lWhGoodsService, |
| | | LWhFormInventoryService lWhFormInventoryService, |
| | | LWhFormProcureCoreService lWhFormProcureCoreService, |
| | | LWhFormOutputServiceImpl lWhFormOutputService |
| | | LWhFormOutputService lWhFormOutputService |
| | | |
| | | ) { |
| | | this.lWhFormInventoryGoods = lWhFormInventoryGoods; |
| | |
| | | package com.consum.base.service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import com.consum.base.core.CodeGeneratorEnum; |
| | | import com.consum.base.core.CodeGeneratorService; |
| | | import com.consum.base.core.type.InventoryStatesType; |
| | | import com.consum.base.core.utils.IdUtil; |
| | | import com.consum.base.core.utils.MapUtils; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | |
| | | import com.walker.infrastructure.utils.DateUtils; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.jdbc.service.BaseServiceImpl; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | /** |
| | | * @Description 盘点 |
| | |
| | | @Lazy |
| | | private LWhFormInventoryCoreService lWhFormInventoryCoreService; |
| | | |
| | | |
| | | private static final String QUERY_LIST = "select * from l_wh_form_inventory where 1=1 "; |
| | | |
| | | private static final String QUERY_PD_List = "SELECT bgt.GOODS_NAME goodsName,model.MODEL_NAME modelName,bgt.CLASSIFICATION,model.UNIT,\n" |
| | | + " record.endCount,bgt.ID goodsTemplateId,model.ID modelsId\n" + "FROM BASE_GOODS_MODELS model\n" |
| | | + " LEFT JOIN (SELECT COUNT(1) endCount, BASE_GOODS_MODELS_ID\n" + " FROM L_WH_GOODS\n" |
| | | + " WHERE WAREHOUSE_TYPE = 0\n" + " AND WAREHOUSE_ID = 1\n" + " AND STATES = ?\n" |
| | | + " GROUP BY BASE_GOODS_MODELS_ID) record ON record.BASE_GOODS_MODELS_ID = model.id\n" |
| | | + "left join base_goods_template bgt on bgt.ID = model.GOODS_TEMPLATES_ID; "; |
| | | |
| | | private static final String QUERY_PD_DETAIL_LIST = |
| | | "SELECT fig.id,fi.WAREHOUSE_NAME,fig.GOODS_TEMPLATE_NAME,fig.BASE_GOODS_MODELS_NAME,fig.INVENTORY_RESULT,fig.INIT_COUNTS,fig.INVENTORY_COUNTS," |
| | |
| | | |
| | | /** |
| | | * @param param |
| | | * @param currentUser 当前登录用户 |
| | | * @param currentUser 当前登录用户 |
| | | * @param operatorUser 盘点人 |
| | | * @param monitorUser 监盘人 |
| | | * @param monitorUser 监盘人 |
| | | * @return |
| | | * @Description 新增 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/31 |
| | | */ |
| | | @Override |
| | | public int add(FormInventoryParam param, FinSysTenantUser currentUser, FinSysTenantUser operatorUser, FinSysTenantUser monitorUser) { |
| | | //新增盘点单 |
| | | public int add(FormInventoryParam param, FinSysTenantUser currentUser, FinSysTenantUser operatorUser, |
| | | FinSysTenantUser monitorUser) { |
| | | // 新增盘点单 |
| | | LWhFormInventory lWhFormInventory = new LWhFormInventory(); |
| | | BeanUtils.copyProperties(param, lWhFormInventory); |
| | | lWhFormInventory.setId(IdUtil.generateId()); |
| | | //盘点单编码 |
| | | // 盘点单编码 |
| | | String businessFormCode = codeGeneratorService.createBusinessFormCode(CodeGeneratorEnum.Inventory); |
| | | lWhFormInventory.setBusinessFormCode(businessFormCode); |
| | | //根据仓库id查询仓库 |
| | | // 根据仓库id查询仓库 |
| | | BaseWarehouse baseWarehouse = this.baseWarehouseService.getById(param.getWarehouseId()); |
| | | if (baseWarehouse != null) { |
| | | lWhFormInventory.setWarehouseName(baseWarehouse.getWarehouseName()); |
| | |
| | | lWhFormInventory.setOperatorName2(monitorUser.getUserName()); |
| | | } |
| | | |
| | | lWhFormInventory.setStates(0); |
| | | lWhFormInventory.setStates(InventoryStatesType.NEW.getValue()); |
| | | lWhFormInventory.setAgencyId(Long.valueOf(currentUser.getTenantId())); |
| | | FinSysTenant finSysTenant = finSysTenantService.selectById(Long.valueOf(currentUser.getTenantId())); |
| | | lWhFormInventory.setAgencyName(finSysTenant.getName()); |
| | |
| | | StringBuilder sql = new StringBuilder(QUERY_LIST); |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | |
| | | //盘点单号 |
| | | // 盘点单号 |
| | | if (!StringUtils.isEmpty(param.getBusinessFormCode())) { |
| | | sql.append("and BUSINESS_FORM_CODE =:BUSINESS_FORM_CODE "); |
| | | paramts.put("BUSINESS_FORM_CODE", param.getBusinessFormCode()); |
| | | } |
| | | //盘点单名称 |
| | | // 盘点单名称 |
| | | if (!StringUtils.isEmpty(param.getBusinessFormName())) { |
| | | sql.append("and BUSINESS_FORM_NAME like :BUSINESS_FORM_NAME "); |
| | | paramts.put("BUSINESS_FORM_NAME", StringUtils.CHAR_PERCENT + param.getBusinessFormName() + StringUtils.CHAR_PERCENT); |
| | | paramts.put("BUSINESS_FORM_NAME", |
| | | StringUtils.CHAR_PERCENT + param.getBusinessFormName() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | //仓库编号 |
| | | // 仓库编号 |
| | | if (param.getWarehouseId() != null) { |
| | | sql.append("and WAREHOUSE_ID =:WAREHOUSE_ID "); |
| | | paramts.put("WAREHOUSE_ID", param.getWarehouseId()); |
| | | } |
| | | //盘点时间 |
| | | // 盘点时间 |
| | | if (param.getStartTime() != null) { |
| | | sql.append("and INVENTORY_DATE >=:inventoryDateStart "); |
| | | paramts.put("inventoryDateStart", param.getStartTime() * 1000000); |
| | |
| | | sql.append("and INVENTORY_DATE <:inventoryDateEnd "); |
| | | paramts.put("inventoryDateEnd", param.getEndTime() * 1000000 + 240000); |
| | | } |
| | | //机构 |
| | | // 机构 |
| | | sql.append("and AGENCY_ID =:AGENCY_ID "); |
| | | paramts.put("AGENCY_ID", sysInfo.getTenantId()); |
| | | |
| | |
| | | return selectSplit(sql.toString(), paramts, new LWhFormInventory()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public FormInventoryVO saveInventory(FormInventoryVO dto, Long id) { |
| | | //1.根据盘点单id查询盘点单 |
| | | // 1.根据盘点单id查询盘点单 |
| | | LWhFormInventory lWhFormInventory = this.get(new LWhFormInventory(id)); |
| | | if (lWhFormInventory == null) { |
| | | log.error("根据盘点单id查询盘点单失败"); |
| | | } |
| | | //2.修改盘点单 |
| | | lWhFormInventory.setStates(1); |
| | | // 2.修改盘点单 |
| | | lWhFormInventory.setStates(InventoryStatesType.PENDING.getValue()); |
| | | lWhFormInventory.setInventoryDate(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | int flag1 = this.update(lWhFormInventory); |
| | | if (flag1 == 0) { |
| | | log.error("修改盘点单失败"); |
| | | } |
| | | //3.添加盘点单物品 |
| | | // 3.添加盘点单物品 |
| | | List<FormInventoryGoodsVO> formInventoryGoodsList = dto.getFormInventoryGoodsList(); |
| | | if (CollectionUtils.isEmpty(formInventoryGoodsList)) { |
| | | log.error("盘点单物品为空"); |
| | |
| | | return dto; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存盘点信息 |
| | | * |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int updateInventoryInfo(LWhFormInventoryParam dto, Integer state, S_user_core currentUser, FinSysTenantUser sysInfo) { |
| | | //1.根据盘点单id查询盘点单 |
| | | public int updateInventoryInfo(LWhFormInventoryParam dto, Integer state, S_user_core currentUser, |
| | | FinSysTenantUser sysInfo) { |
| | | // 1.根据盘点单id查询盘点单 |
| | | LWhFormInventory lWhFormInventory = this.get(new LWhFormInventory(dto.getId())); |
| | | if (lWhFormInventory == null) { |
| | | log.error("根据盘点单id查询盘点单失败"); |
| | | return 0; |
| | | } |
| | | //添加盘点单物品 |
| | | // 添加盘点单物品 |
| | | List<FormInventoryGoodsVO> inventoryGoodsList = dto.getInventoryGoodsList(); |
| | | if (CollectionUtils.isEmpty(inventoryGoodsList)) { |
| | | log.error("盘点单物品为空"); |
| | | return 0; |
| | | } |
| | | this.inventoryGoodsService.updateInventoryGoods(inventoryGoodsList); |
| | | //修改盘点单 |
| | | // 修改盘点单 |
| | | if (state == 2) { |
| | | //完成盘点时设置完成盘点时间 |
| | | // 完成盘点时设置完成盘点时间 |
| | | lWhFormInventory.setStopTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | |
| | | //完成盘点时设置完成盘点时间 |
| | | String inOutFormByInventoryId = lWhFormInventoryCoreService.createInOutFormByInventoryId(dto.getId(), currentUser, sysInfo); |
| | | // 完成盘点时设置完成盘点时间 |
| | | String inOutFormByInventoryId = |
| | | lWhFormInventoryCoreService.createInOutFormByInventoryId(dto.getId(), currentUser, sysInfo); |
| | | if (!StringUtils.isEmpty(inOutFormByInventoryId)) { |
| | | log.error(inOutFormByInventoryId); |
| | | return 0; |
| | |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @return |
| | | * @Description 异常明细列表查询 |
| | |
| | | StringBuilder sql = new StringBuilder(QUERY_PD_DETAIL_LIST); |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | |
| | | //机构 |
| | | // 机构 |
| | | sql.append(" and AGENCY_ID like:AGENCY_ID "); |
| | | if (param.getAgencyId() != null) { |
| | | paramts.put("AGENCY_ID", param.getAgencyId() + StringUtils.CHAR_PERCENT); |
| | | } else { |
| | | paramts.put("AGENCY_ID", sysInfo.getTenantId() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | //仓库编号 |
| | | // 仓库编号 |
| | | if (param.getWarehouseId() != null) { |
| | | sql.append("and WAREHOUSE_ID =:WAREHOUSE_ID "); |
| | | paramts.put("WAREHOUSE_ID", param.getWarehouseId()); |
| | | } |
| | | //物品名称 |
| | | // 物品名称 |
| | | if (!StringUtils.isEmpty(param.getGoodsTemplateName())) { |
| | | sql.append("and GOODS_TEMPLATE_NAME =:GOODS_TEMPLATE_NAME "); |
| | | paramts.put("GOODS_TEMPLATE_NAME", StringUtils.CHAR_PERCENT + param.getGoodsTemplateName() + StringUtils.CHAR_PERCENT); |
| | | paramts.put("GOODS_TEMPLATE_NAME", |
| | | StringUtils.CHAR_PERCENT + param.getGoodsTemplateName() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | //规格型号 |
| | | // 规格型号 |
| | | if (param.getBaseGoodsModelsId() != null) { |
| | | sql.append("and BASE_GOODS_MODELS_ID =:BASE_GOODS_MODELS_ID "); |
| | | paramts.put("BASE_GOODS_MODELS_ID", param.getBaseGoodsModelsId()); |
| | | } |
| | | //类型(出入库类型) |
| | | // 类型(出入库类型) |
| | | Integer inventoryResult = param.getInventoryResult(); |
| | | if (inventoryResult != null) { |
| | | sql.append("and INVENTORY_RESULT =:INVENTORY_RESULT "); |
| | | paramts.put("INVENTORY_RESULT", inventoryResult); |
| | | } |
| | | //出入库单号 |
| | | // 出入库单号 |
| | | if (param.getWarehouseFormCode() != null) { |
| | | sql.append( |
| | | " and CASE WHEN fig.INVENTORY_RESULT = 2 THEN fi.IN_BUSINESS_FORM_CODE =:warehouseFormCode WHEN fig.INVENTORY_RESULT = 3 THEN fi.OUT_BUSINESS_FORM_CODE =:warehouseFormCode END "); |
| | | paramts.put("warehouseFormCode", param.getWarehouseFormCode()); |
| | | } |
| | | //操作人 |
| | | // 操作人 |
| | | if (!StringUtils.isEmpty(param.getOperatorName())) { |
| | | sql.append("and OPERATOR_NAME =:OPERATOR_NAME "); |
| | | paramts.put("OPERATOR_NAME", StringUtils.CHAR_PERCENT + param.getOperatorName() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | //结束时间 |
| | | // 结束时间 |
| | | if (param.getStartTime() != null) { |
| | | sql.append("and STOP_TIME >=:stopTimeStart "); |
| | | paramts.put("stopTimeStart", param.getStartTime() * 1000000); |
| | |
| | | } |
| | | sql.append("AND fig.INVENTORY_RESULT in(2,3) "); |
| | | sql.append("ORDER BY CREATE_TIME DESC "); |
| | | GenericPager<Map<String, Object>> mapGenericPager = selectSplit(sql.toString(), paramts, param.getPageNum(), param.getPageSize(), new MapperUtil()); |
| | | GenericPager<Map<String, Object>> mapGenericPager = |
| | | selectSplit(sql.toString(), paramts, param.getPageNum(), param.getPageSize(), new MapperUtil()); |
| | | PageUtil<FormInventoryDetailVO> pageUtil = new PageUtil<>(mapGenericPager); |
| | | List<FormInventoryDetailVO> result = Lists.newArrayList(); |
| | | mapGenericPager.getDatas().forEach(item -> { |
| | | FormInventoryDetailVO formInventoryDetailVO = MapUtils.convertMapToObj(item, FormInventoryDetailVO.class); |
| | | formInventoryDetailVO.setInventoryResultType( |
| | | formInventoryDetailVO.getInventoryResult() == null ? null : (formInventoryDetailVO.getInventoryResult() == 2 ? "盘盈" : "盘亏")); |
| | | formInventoryDetailVO.setInventoryType( |
| | | formInventoryDetailVO.getInventoryResult() == null ? null : (formInventoryDetailVO.getInventoryResult() == 2 ? "盘盈入库" : "盘亏出库")); |
| | | formInventoryDetailVO.setInventoryResultType(formInventoryDetailVO.getInventoryResult() == null ? null |
| | | : (formInventoryDetailVO.getInventoryResult() == 2 ? "盘盈" : "盘亏")); |
| | | formInventoryDetailVO.setInventoryType(formInventoryDetailVO.getInventoryResult() == null ? null |
| | | : (formInventoryDetailVO.getInventoryResult() == 2 ? "盘盈入库" : "盘亏出库")); |
| | | formInventoryDetailVO.setWarehouseFormCode(formInventoryDetailVO.getWarehouseFormCode()); |
| | | result.add(formInventoryDetailVO); |
| | | }); |
| | |
| | | List<FormInventoryGoodsVO> goodsVOList = Lists.newArrayList(); |
| | | result.forEach(item -> { |
| | | FormInventoryGoodsVO baseGoodsModels = MapUtils.convertMapToObj(item, FormInventoryGoodsVO.class); |
| | | int inventoryCount = this.lWhGoodsService.queryGoodsModelNum(warehouseType, warehouseId, baseGoodsModels.getId(), 1, null); |
| | | int inventoryCount = |
| | | this.lWhGoodsService.queryGoodsModelNum(warehouseType, warehouseId, baseGoodsModels.getId(), 1, null); |
| | | baseGoodsModels.setInventoryCount(inventoryCount); |
| | | goodsVOList.add(baseGoodsModels); |
| | | }); |
| | |
| | | |
| | | @Override |
| | | public List<InventoryExcelTemplate> getExportList(Long id) { |
| | | String sql = "SELECT\n" |
| | | + "\tfi.INVENTORY_DATE createTime,\n" |
| | | + "\tfi.STOP_TIME endTime,\n" |
| | | + "\tfi.OPERATOR_NAME,\n" |
| | | + "\tfi.OPERATOR_NAME2 monitorName,\n" |
| | | + "\tfi.AGENCY_NAME tenantName,\n" |
| | | + "\tfig.GOODS_TEMPLATE_NAME templateName,\n" |
| | | + "\tfig.BASE_GOODS_MODELS_NAME baseModelName,\n" |
| | | + "\tfig.INVENTORY_COUNTS num,\n" |
| | | + "\tfig.INIT_COUNTS stockNum,\n" |
| | | + "\tfig.INVENTORY_RESULT,\n" |
| | | + "\tBEIZ1 remark\n" |
| | | + "FROM\n" |
| | | + "\tl_wh_form_inventory fi\n" |
| | | + "\tLEFT JOIN l_wh_form_inventory_goods fig ON fi.ID = fig.WH_FORM_INVENTORY_ID\n" |
| | | + "WHERE\n" |
| | | String sql = "SELECT\n" + "\tfi.INVENTORY_DATE createTime,\n" + "\tfi.STOP_TIME endTime,\n" |
| | | + "\tfi.OPERATOR_NAME,\n" + "\tfi.OPERATOR_NAME2 monitorName,\n" + "\tfi.AGENCY_NAME tenantName,\n" |
| | | + "\tfig.GOODS_TEMPLATE_NAME templateName,\n" + "\tfig.BASE_GOODS_MODELS_NAME baseModelName,\n" |
| | | + "\tfig.INVENTORY_COUNTS num,\n" + "\tfig.INIT_COUNTS stockNum,\n" + "\tfig.INVENTORY_RESULT,\n" |
| | | + "\tBEIZ1 remark\n" + "FROM\n" + "\tl_wh_form_inventory fi\n" |
| | | + "\tLEFT JOIN l_wh_form_inventory_goods fig ON fi.ID = fig.WH_FORM_INVENTORY_ID\n" + "WHERE\n" |
| | | + "\tfi.ID = :id"; |
| | | HashMap<String, Object> param = new HashMap<>(); |
| | | param.put("id", id); |
| | |
| | | } |
| | | List<InventoryExcelTemplate> list = Lists.newArrayList(); |
| | | select.forEach(item -> { |
| | | InventoryExcelTemplate inventoryExcelTemplate = MapUtils.convertMapToObj(item, InventoryExcelTemplate.class); |
| | | InventoryExcelTemplate inventoryExcelTemplate = |
| | | MapUtils.convertMapToObj(item, InventoryExcelTemplate.class); |
| | | inventoryExcelTemplate.setInventoryDeception(inventoryExcelTemplate.getInventoryResult() == 1 ? "是" : "否"); |
| | | inventoryExcelTemplate.setDeception( |
| | | inventoryExcelTemplate.getInventoryResult() == 1 ? "正常" : (inventoryExcelTemplate.getInventoryResult() == 2 ? "盘盈" : "盘亏")); |
| | | inventoryExcelTemplate.setDeception(inventoryExcelTemplate.getInventoryResult() == 1 ? "正常" |
| | | : (inventoryExcelTemplate.getInventoryResult() == 2 ? "盘盈" : "盘亏")); |
| | | list.add(inventoryExcelTemplate); |
| | | }); |
| | | return list; |
| | |
| | | package com.consum.base.service; |
| | | |
| | | import com.consum.model.po.WhFormOutput; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.jdbc.service.BaseServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.consum.base.pojo.LWhFormOutputParam; |
| | | import com.consum.base.pojo.excel.OutputExcelTemplate; |
| | | import com.consum.base.pojo.query.LWhFormOutputQry; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.jdbc.service.BaseService; |
| | | |
| | | /** |
| | | * @ClassName WhFormOutputService |
| | | |
| | | * |
| | | * @Date 2023/10/26 |
| | | * @Description |
| | | * @Version 1.0 |
| | | **/ |
| | | @Slf4j |
| | | @Service |
| | | public class LWhFormOutputService extends BaseServiceImpl { |
| | | public interface LWhFormOutputService extends BaseService { |
| | | |
| | | int add(LWhFormOutputParam param, S_user_core currentUser, FinSysTenantUser sysInfo); |
| | | |
| | | GenericPager queryFormOutputList(LWhFormOutputQry param); |
| | | |
| | | GenericPager<Map<String, Object>> queryFormOutputDetailList(LWhFormOutputQry param); |
| | | |
| | | /** |
| | | * 导出出库单 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | List<OutputExcelTemplate> getExportList(Long id); |
| | | |
| | | /** |
| | | * 通过调拨单查询出库单id |
| | |
| | | * @param transBusinessId |
| | | * @return |
| | | */ |
| | | private static String QUEYR_ID_BY_TRANSFERID = "select id from L_WH_FORM_OUTPUT where TRANS_BUSINESS_ID =:transBusinessId limit 1"; |
| | | |
| | | public Long queyrIdByTransferId(Long transBusinessId) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("transBusinessId", transBusinessId); |
| | | List<WhFormOutput> whFormOutputs = select(QUEYR_ID_BY_TRANSFERID, map, new WhFormOutput()); |
| | | if (CollectionUtils.isEmpty(whFormOutputs)) { |
| | | return null; |
| | | } |
| | | return whFormOutputs.get(0).getId(); |
| | | } |
| | | Long queyrIdByTransferId(Long transBusinessId); |
| | | } |
| | |
| | | package com.consum.base.service; |
| | | |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.jdbc.service.BaseServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.consum.base.pojo.dto.GoodsModelCountDTO; |
| | | import com.walker.jdbc.service.BaseService; |
| | | |
| | | /** |
| | | * @ClassName LWhGoodsService |
| | | * @Date 2023/10/24 |
| | | * @Description |
| | | * @Version 1.0 |
| | | * LWhGoodsService |
| | | * |
| | | * @author asus |
| | | * @version 2023/12/05 13:52 |
| | | **/ |
| | | @Service |
| | | public class LWhGoodsService extends BaseServiceImpl { |
| | | public interface LWhGoodsService extends BaseService { |
| | | int queryGoodsModelNum(Integer warehouseType, Long warehouseId, Long baseGoodsModelsId, Integer states, |
| | | Integer buyType); |
| | | |
| | | List<Map<String, Object>> queryOutGoods(Integer warehouseType, Long warehouseId, Long baseGoodsModelsId, |
| | | Integer states, Integer buyType, Integer goodsModelNum); |
| | | |
| | | List<Long> queryOutGoodsId(Integer warehouseType, Long warehouseId, Long baseGoodsModelsId, Integer states, |
| | | Integer buyType, Integer goodsModelNum); |
| | | |
| | | long queryGoodsPriceById(List<Long> goodsIds); |
| | | |
| | | List<Map<String, Object>> queryScrappedGoods(Integer warehouseType, Long warehouseId, Long transBusinessId, |
| | | String nowUserName, Long baseGoodsModelsId, Short states, Integer goodsModelNum); |
| | | |
| | | List<Long> queryScrappedGoodsIds(Integer warehouseType, Long warehouseId, Long transBusinessId, String nowUserName, |
| | | Long baseGoodsModelsId, Short states, Integer goodsModelNum); |
| | | |
| | | int modGoodsTransfering(List<Long> whGoods, Integer warehouseType, Long toWarehouseId, String toWarehouseName, |
| | | Integer states); |
| | | |
| | | // 按机构统计物品价值、数量/金额等 |
| | | List<Map<String, Object>> getGoodsNumPrice(Long agencyId); |
| | | |
| | | // 按机构统计物品价值、数量/金额等 |
| | | List<Map<String, Object>> getGoodsNumByMonth(Long agencyId); |
| | | |
| | | /** |
| | | * @param warehouseType 仓库类型0机构1部门 |
| | | * @param warehouseId 所属仓库仓库编号 |
| | | * @param baseGoodsModelsId 规格型号编号 |
| | | * @param states (0=在途调拨;1=入库未分发;2=已下发;3=报废) |
| | | * @param buyType 采购方式(1:集采;2=自采) |
| | | * @return 查询某个型号在仓库中的数量 |
| | | */ |
| | | private static String query_Goods_Model_Num = "SELECT COUNT(1) from L_WH_GOODS where 1=1"; |
| | | |
| | | public int queryGoodsModelNum(Integer warehouseType, Long warehouseId, Long baseGoodsModelsId, Integer states, Integer buyType) { |
| | | StringBuilder sql = new StringBuilder(query_Goods_Model_Num); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | |
| | | if (warehouseType != null) { |
| | | sql.append(" and WAREHOUSE_TYPE=:warehouseType"); |
| | | paramts.put("warehouseType", warehouseType); |
| | | } |
| | | if (warehouseId != null) { |
| | | sql.append(" and WAREHOUSE_ID=:warehouseId"); |
| | | paramts.put("warehouseId", warehouseId); |
| | | } |
| | | if (baseGoodsModelsId != null) { |
| | | sql.append(" and BASE_GOODS_MODELS_ID=:baseGoodsModelsId"); |
| | | paramts.put("baseGoodsModelsId", baseGoodsModelsId); |
| | | } |
| | | if (states != null) { |
| | | sql.append(" and STATES=:states"); |
| | | paramts.put("states", states); |
| | | } |
| | | if (buyType != null) { |
| | | sql.append(" and BUY_TYPE=:buyType"); |
| | | paramts.put("buyType", buyType); |
| | | } |
| | | return queryForInt(sql.toString(), paramts); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 出库时候,先入库的先出库,同时入库的,按价格高的先出库 |
| | | * |
| | | * @param warehouseId 所属仓库仓库编号 |
| | | * @param baseGoodsModelsId 规格型号编号 |
| | | * @param states 状态(0=在途调拨;1=入库未分发;2=已下发;3=报废) |
| | | * @param buyType 采购方式(1:集采;2=自采) |
| | | * @param goodsModelNum 取出的数量 |
| | | * 根据型号查询商品总价 |
| | | * |
| | | * @param baseGoodsModelsId |
| | | * @param type <br> |
| | | * 状态(0=在途调拨;1=入库未分发;2=已下发;3=报废 4 零星出库 |
| | | * @return |
| | | */ |
| | | private static String QUERY_OUT_GOODS_ID = "SELECT * FROM L_WH_GOODS WHERE 1=1"; |
| | | |
| | | public List<Map<String, Object>> queryOutGoods(Integer warehouseType, Long warehouseId, Long baseGoodsModelsId, Integer states, Integer buyType, |
| | | Integer goodsModelNum) { |
| | | StringBuilder sql = new StringBuilder(QUERY_OUT_GOODS_ID); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | if (warehouseType != null) { |
| | | sql.append(" and WAREHOUSE_TYPE=:warehouseType"); |
| | | paramts.put("warehouseType", warehouseType); |
| | | } |
| | | if (warehouseId != null) { |
| | | sql.append(" and WAREHOUSE_ID=:warehouseId"); |
| | | paramts.put("warehouseId", warehouseId); |
| | | } |
| | | if (baseGoodsModelsId != null) { |
| | | sql.append(" and BASE_GOODS_MODELS_ID=:baseGoodsModelsId"); |
| | | paramts.put("baseGoodsModelsId", baseGoodsModelsId); |
| | | } |
| | | if (states != null) { |
| | | sql.append(" and STATES=:states"); |
| | | paramts.put("states", states); |
| | | } |
| | | if (buyType != null) { |
| | | sql.append(" and BUY_TYPE=:buyType"); |
| | | paramts.put("buyType", buyType); |
| | | } |
| | | return select(sql.append(" limit ").append(goodsModelNum).toString(), paramts); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 出库时候,先入库的先出库,同时入库的,按价格高的先出库 |
| | | * |
| | | * @param warehouseId 所属仓库仓库编号 |
| | | * @param baseGoodsModelsId 规格型号编号 |
| | | * @param states 状态(0=在途调拨;1=入库未分发;2=已下发;3=报废) |
| | | * @param buyType 采购方式(1:集采;2=自采) |
| | | * @param goodsModelNum 取出的数量 |
| | | * @return |
| | | */ |
| | | public List<Long> queryOutGoodsId(Integer warehouseType, Long warehouseId, Long baseGoodsModelsId, Integer states, Integer buyType, Integer goodsModelNum) { |
| | | List<Map<String, Object>> outGoods = queryOutGoods(warehouseType, warehouseId, baseGoodsModelsId, states, buyType, goodsModelNum); |
| | | if (CollectionUtils.isEmpty(outGoods)) { |
| | | return null; |
| | | } |
| | | List<Long> whGoodsIds = outGoods.stream().map(map -> (Long) map.get("id")).collect(Collectors.toList()); |
| | | return whGoodsIds; |
| | | } |
| | | |
| | | private static String QUERY_GOODS_PRICE_BY_ID = "SELECT sum(PRICE)totalPrice from L_WH_GOODS goods where 1=1"; |
| | | |
| | | public long queryGoodsPriceById(List<Long> goodsIds) { |
| | | StringBuilder sql = new StringBuilder(QUERY_GOODS_PRICE_BY_ID); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(goodsIds)) { |
| | | sql.append(" and id in(:goodsIds)"); |
| | | paramts.put("goodsIds", goodsIds); |
| | | } |
| | | List<Map<String, Object>> map = this.select(sql.toString(), paramts); |
| | | if (CollectionUtils.isEmpty(map)) { |
| | | return 0; |
| | | } |
| | | BigDecimal totalPrice = (BigDecimal) map.get(0).get("totalPrice"); |
| | | return totalPrice.longValue(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询报废物品 默认优先报废最高价的物品 |
| | | * |
| | | * @param warehouseType |
| | | * @param warehouseId |
| | | * @param transBusinessId 调拨单号 |
| | | * @param nowUserName 使用人姓名 |
| | | * @param baseGoodsModelsId 物品型号 |
| | | * @param states 状态(0=在途调拨;1=入库未分发;2=已下发;3=报废 4 零星出库) |
| | | * @param goodsModelNum 取出的数量 |
| | | * @return |
| | | */ |
| | | |
| | | private static String QUERY_SCRAPPED_GOODS_PREFIX_1 = "SELECT goods.id, goods.PRICE FROM L_WH_GOODS goods LEFT JOIN L_GOODS_USER_RECORD useRecord ON goods.id=useRecord.WH_GOODS_ID AND useRecord.LAST_RECORD=1 WHERE 1=1 "; |
| | | private static String QUERY_SCRAPPED_GOODS_PREFIX_2 = " AND goods.id IN (SELECT lwgrd.WH_GOODS_ID FROM L_WAREHOUSE_FLOW flow LEFT JOIN L_WH_GOODS_RECORD lwgr ON lwgr.WAREHOUSE_FLOW_ID=flow.id LEFT JOIN L_WH_GOODS_RECORD_DETAILS lwgrd ON lwgrd.WH_GOODS_RECORD_ID=lwgr.id WHERE flow.THIS_TYPE=1 AND flow.BUSINESS_FORM_ID=:transBusinessId)"; |
| | | private static String QUERY_SCRAPPED_GOODS_PREFIX_2_MODEL_NOT_NULL = " AND goods.id IN (SELECT lwgrd.WH_GOODS_ID FROM L_WAREHOUSE_FLOW flow LEFT JOIN L_WH_GOODS_RECORD lwgr ON lwgr.WAREHOUSE_FLOW_ID=flow.id LEFT JOIN L_WH_GOODS_RECORD_DETAILS lwgrd ON lwgrd.WH_GOODS_RECORD_ID=lwgr.id WHERE flow.THIS_TYPE=1 AND flow.BUSINESS_FORM_ID=:transBusinessId AND lwgr.BASE_GOODS_MODELS_ID = :lwgrGoodsModelId)"; |
| | | private static String QUERY_SCRAPPED_GOODS_END = " ORDER BY goods.PRICE DESC,goods.PROCURE_DATE ASC,goods.id"; |
| | | |
| | | public List<Map<String, Object>> queryScrappedGoods(Integer warehouseType, |
| | | Long warehouseId, |
| | | Long transBusinessId, |
| | | String nowUserName, |
| | | Long baseGoodsModelsId, |
| | | Short states, |
| | | Integer goodsModelNum) { |
| | | if (warehouseType == null) { |
| | | warehouseType = 0; |
| | | } |
| | | StringBuilder sql = new StringBuilder(QUERY_SCRAPPED_GOODS_PREFIX_1); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | if (warehouseType != null) { |
| | | sql.append(" AND goods.WAREHOUSE_TYPE=:warehouseType"); |
| | | paramts.put("warehouseType", warehouseType); |
| | | } |
| | | if (warehouseId != null) { |
| | | sql.append(" AND goods.WAREHOUSE_ID=:warehouseId"); |
| | | paramts.put("warehouseId", warehouseId); |
| | | } |
| | | if (StringUtils.isNotEmpty(nowUserName)) { |
| | | sql.append(" AND useRecord.NOW_USER_NAME=:nowUserName"); |
| | | paramts.put("nowUserName", nowUserName); |
| | | } |
| | | if (baseGoodsModelsId != null) { |
| | | sql.append(" AND goods.BASE_GOODS_MODELS_ID=:baseGoodsModelsId"); |
| | | paramts.put("baseGoodsModelsId", baseGoodsModelsId); |
| | | } |
| | | if (states != null) { |
| | | sql.append(" AND goods.STATES=:states"); |
| | | paramts.put("states", states); |
| | | } |
| | | if (transBusinessId != null) { |
| | | if (baseGoodsModelsId != null) { |
| | | sql.append(QUERY_SCRAPPED_GOODS_PREFIX_2_MODEL_NOT_NULL); |
| | | paramts.put("transBusinessId", transBusinessId); |
| | | paramts.put("lwgrGoodsModelId", baseGoodsModelsId); |
| | | } else { |
| | | sql.append(QUERY_SCRAPPED_GOODS_PREFIX_2); |
| | | paramts.put("transBusinessId", transBusinessId); |
| | | } |
| | | } |
| | | sql.append(QUERY_SCRAPPED_GOODS_END); |
| | | if (goodsModelNum != null) { |
| | | sql.append(" limit ").append(goodsModelNum); |
| | | } |
| | | return select(sql.toString(), paramts); |
| | | } |
| | | |
| | | /** |
| | | * 查询报废物品 默认优先报废最高价的物品 |
| | | * |
| | | * @param warehouseType |
| | | * @param warehouseId |
| | | * @param transBusinessId 调拨单号 |
| | | * @param nowUserName 使用人姓名 |
| | | * @param baseGoodsModelsId 物品型号 |
| | | * @param states 状态(0=在途调拨;1=入库未分发;2=已下发;3=报废 4 零星出库) |
| | | * @param goodsModelNum 取出的数量 |
| | | * @return |
| | | */ |
| | | public List<Long> queryScrappedGoodsIds(Integer warehouseType, |
| | | Long warehouseId, |
| | | Long transBusinessId, |
| | | String nowUserName, |
| | | Long baseGoodsModelsId, |
| | | Short states, |
| | | Integer goodsModelNum) { |
| | | List<Map<String, Object>> outGoods = queryScrappedGoods(warehouseType, warehouseId, transBusinessId, nowUserName, baseGoodsModelsId, states, |
| | | goodsModelNum); |
| | | if (CollectionUtils.isEmpty(outGoods)) { |
| | | return null; |
| | | } |
| | | List<Long> whGoodsIds = outGoods.stream().map(map -> (Long) map.get("id")).collect(Collectors.toList()); |
| | | return whGoodsIds; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置物品状态为调拨中 |
| | | * |
| | | * @param whGoods |
| | | * @param toWarehouseId |
| | | * @param toWarehouseName |
| | | * @return |
| | | */ |
| | | private static String MOD_GOODS_TRANSFERING_PREFIX = "update L_WH_GOODS set "; |
| | | |
| | | public int modGoodsTransfering(List<Long> whGoods, Integer warehouseType, Long toWarehouseId, String toWarehouseName, Integer states) { |
| | | StringBuilder sql = new StringBuilder(MOD_GOODS_TRANSFERING_PREFIX); |
| | | ArrayList<Object> params = new ArrayList<>(); |
| | | if (warehouseType != null) { |
| | | sql.append(", WAREHOUSE_TYPE=?"); |
| | | params.add(warehouseType); |
| | | } |
| | | if (toWarehouseId != null) { |
| | | sql.append(", WAREHOUSE_ID=?"); |
| | | params.add(toWarehouseId); |
| | | } |
| | | if (toWarehouseName != null) { |
| | | sql.append(", WAREHOUSE_NAME=?"); |
| | | params.add(toWarehouseName); |
| | | } |
| | | if (states != null) { |
| | | sql.append(", STATES=?"); |
| | | params.add(states); |
| | | } |
| | | sql.deleteCharAt(22); |
| | | sql.append(" where id in(").append(StringUtils.join(whGoods, ",")).append(")"); |
| | | return update(sql.toString(), params.toArray()); |
| | | } |
| | | |
| | | private static String GOODS_NUM_PRICE = "SELECT t.tenantId,count(id) total_Num,count(CASE WHEN STATES=2 THEN 1 END) xia_fa_num,IFNULL(round(sum(PRICE)/1000000,2),0) total_price,IFNULL(ROUND(count(CASE WHEN STATES=2 THEN 1 END)/count(id),4),0)*100 AS zhan_you_percent,count(CASE COST_TYPE WHEN 1 THEN 1 END) a_total_Num,count(CASE COST_TYPE WHEN 2 THEN 1 END) b_total_Num,count(CASE COST_TYPE WHEN 3 THEN 1 END) c_total_Num,IFNULL( round( sum( CASE COST_TYPE WHEN 1 THEN PRICE END )/ 1000000, 2 ), 0 ) a_total_price,IFNULL( round( sum( CASE COST_TYPE WHEN 2 THEN PRICE END )/ 1000000, 2 ), 0 ) b_total_price,IFNULL( round( sum( CASE COST_TYPE WHEN 3 THEN PRICE END )/ 1000000, 2 ), 0 ) c_total_price FROM (SELECT tCangKu.tenantId,tKuCun.id,tKuCun.STATES,tKuCun.COST_TYPE,tKuCun.price FROM (SELECT tenant.id tenantId,tenant.NAME AS org_name,ware.*FROM fin_sys_tenant tenant RIGHT JOIN ( SELECT 0 WAREHOUSE_TYPE,id,AGENCY_ID,WAREHOUSE_NAME FROM BASE_WAREHOUSE UNION ALL SELECT 1 WAREHOUSE_TYPE,id,TENANT_ID AGENCY_ID,`NAME` WAREHOUSE_NAME FROM fin_sys_tenant_department) ware ON tenant.id=ware.AGENCY_ID WHERE 1=1 "; |
| | | private static String GOODS_NUM_PRICE_END = ") tCangKu LEFT JOIN L_WH_GOODS tKuCun ON tCangKu.WAREHOUSE_TYPE=tKuCun.WAREHOUSE_TYPE AND tCangKu.id=tKuCun.WAREHOUSE_ID AND tKuCun.STATES BETWEEN 1 AND 2 where tKuCun.id is not null) t GROUP BY t.tenantId"; |
| | | |
| | | //按机构统计物品价值、数量/金额等 |
| | | public List<Map<String, Object>> getGoodsNumPrice(Long agencyId) { |
| | | StringBuilder sql = new StringBuilder(GOODS_NUM_PRICE); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | sql.append(" and tenant.id=:agencyId"); |
| | | paramts.put("agencyId", agencyId); |
| | | return select(sql.append(GOODS_NUM_PRICE_END).toString(), paramts, new MapperUtil()); |
| | | } |
| | | |
| | | |
| | | private static String GET_GOODS_NUM_BY_MONTH = "SELECT monthT.month_Num,IFNULL(datat.total_Num,0) total_Num,IFNULL(datat.add_total_Num,0) add_total_Num,IFNULL(datat.reduce_total_Num,0) reduce_total_Num FROM (SELECT monthT.month_Num FROM (SELECT ( SELECT 1) month_Num UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10 UNION SELECT 11 UNION SELECT 12) monthT) monthT LEFT JOIN ( SELECT t.tenantId,count(t.THIS_COUNT) total_Num,count(CASE t.THIS_TYPE WHEN 1 THEN t.THIS_COUNT END) add_total_Num,count(CASE t.THIS_TYPE WHEN 2 THEN t.THIS_COUNT END) reduce_total_Num,SUBSTR(DEAL_TIME,5,2) data_month FROM ( SELECT tCangKu.tenantId,tKuCun.id,tKuCun.THIS_TYPE,tKuCun.THIS_COUNT,tKuCun.DEAL_TIME FROM (SELECT tenant.id tenantId,tenant.NAME AS org_name,ware.*FROM fin_sys_tenant tenant RIGHT JOIN ( SELECT 0 WAREHOUSE_TYPE,id,AGENCY_ID,WAREHOUSE_NAME FROM BASE_WAREHOUSE UNION ALL SELECT 1 WAREHOUSE_TYPE,id,TENANT_ID AGENCY_ID,`NAME` WAREHOUSE_NAME FROM fin_sys_tenant_department) ware ON tenant.id=ware.AGENCY_ID WHERE 1=1 "; |
| | | private static String GET_GOODS_NUM_BY_MONTH_END = ")tCangKu LEFT JOIN L_WH_GOODS_RECORD tKuCun ON tCangKu.WAREHOUSE_TYPE=tKuCun.WAREHOUSE_TYPE AND tCangKu.id=tKuCun.WAREHOUSE_ID and tKuCun.DEAL_TIME between cast(CONCAT(DATE_FORMAT(NOW(), '%Y'),'1231240000') as UNSIGNED) and cast(CONCAT(DATE_FORMAT(NOW(), '%Y'),'0101000000') as UNSIGNED)) t GROUP BY t.tenantId,SUBSTR(DEAL_TIME,5,2)) datat ON datat.data_month=monthT.month_Num ORDER BY monthT.month_Num ASC"; |
| | | |
| | | //按机构统计物品价值、数量/金额等 |
| | | public List<Map<String, Object>> getGoodsNumByMonth(Long agencyId) { |
| | | StringBuilder sql = new StringBuilder(GET_GOODS_NUM_BY_MONTH); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | sql.append(" and tenant.id=:agencyId"); |
| | | paramts.put("agencyId", agencyId); |
| | | return select(sql.append(GET_GOODS_NUM_BY_MONTH_END).toString(), paramts, new MapperUtil()); |
| | | } |
| | | GoodsModelCountDTO queryGoodsAmount(Long baseGoodsModelsId, Integer type); |
| | | } |
File was renamed from consum-base/src/main/java/com/consum/base/service/LWhFormOutputServiceImpl.java |
| | |
| | | package com.consum.base.service; |
| | | package com.consum.base.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | |
| | | import com.consum.base.core.CodeGeneratorService; |
| | | import com.consum.base.core.WhBusinessEnum; |
| | | import com.consum.base.core.param.BaseWarehouseParam1; |
| | | import com.consum.base.core.type.GoodsModelType; |
| | | import com.consum.base.core.type.OutPutStatesType; |
| | | import com.consum.base.core.utils.CurrencyUtil; |
| | | import com.consum.base.core.utils.IdUtil; |
| | | import com.consum.base.core.utils.MapUtils; |
| | |
| | | import com.consum.base.pojo.LWhFormOutputParam; |
| | | import com.consum.base.pojo.excel.OutputExcelTemplate; |
| | | import com.consum.base.pojo.query.LWhFormOutputQry; |
| | | import com.consum.base.service.BaseGoodsModelsService; |
| | | import com.consum.base.service.BaseWarehouseService; |
| | | import com.consum.base.service.LWhFormOutputCoreService; |
| | | import com.consum.base.service.LWhFormOutputService; |
| | | import com.consum.base.service.LWhGoodsService; |
| | | import com.consum.base.service.LWhProcureModelService; |
| | | import com.consum.model.po.BaseGoodsModels; |
| | | import com.consum.model.po.BaseWarehouse; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhFormOutput; |
| | | import com.consum.model.po.LWhProcureModel; |
| | | import com.consum.model.po.WhFormOutput; |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class LWhFormOutputServiceImpl extends BaseServiceImpl { |
| | | public class LWhFormOutputServiceImpl extends BaseServiceImpl implements LWhFormOutputService { |
| | | |
| | | @Autowired |
| | | private CodeGeneratorService codeGeneratorService; |
| | |
| | | @Autowired |
| | | private LWhProcureModelService lWhProcureModelService; |
| | | @Autowired |
| | | @Lazy |
| | | private LWhFormOutputCoreService lWhFormOutputCoreService; |
| | | @Autowired |
| | | private BaseGoodsModelsService baseGoodsModelsService; |
| | |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/27 |
| | | */ |
| | | @Override |
| | | public int add(LWhFormOutputParam param, S_user_core currentUser, FinSysTenantUser sysInfo) { |
| | | // 1.新增出库单记录 |
| | | LWhFormOutput lWhFormOutput = new LWhFormOutput(); |
| | |
| | | lWhFormOutput.setOperatorId(sysInfo.getId()); |
| | | lWhFormOutput.setOperatorName(sysInfo.getUserName()); |
| | | lWhFormOutput.setDealTime(param.getDealTime()); |
| | | lWhFormOutput.setStates(1); |
| | | lWhFormOutput.setStates(OutPutStatesType.OUT_PENDING.getValue()); |
| | | lWhFormOutput.setOutputDoc(param.getProcureDoc()); |
| | | int flag1 = this.insert(lWhFormOutput); |
| | | if (flag1 == 0) { |
| | |
| | | for (LWFormsOutputGoodsModelParam model : models) { |
| | | LWhProcureModel lWhProcureModel = new LWhProcureModel(); |
| | | lWhProcureModel.setId(IdUtil.generateId()); |
| | | lWhProcureModel.setBusinessType(3); |
| | | lWhProcureModel.setBusinessType(GoodsModelType.OUT_PUT.getValue()); |
| | | lWhProcureModel.setBusinessId(lWhFormOutputId); |
| | | lWhProcureModel.setBaseGoodsModelsId(model.getBaseGoodsModelsId()); |
| | | // 根据型号id查询型号 |
| | |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/30 |
| | | */ |
| | | @Override |
| | | public GenericPager queryFormOutputList(LWhFormOutputQry param) { |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | StringBuilder sql = new StringBuilder(QUERY_FORM_OUTPUT_LIST); |
| | |
| | | return genericPager; |
| | | } |
| | | |
| | | @Override |
| | | public GenericPager<Map<String, Object>> queryFormOutputDetailList(LWhFormOutputQry param) { |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | StringBuilder sql = |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<OutputExcelTemplate> getExportList(Long id) { |
| | | String sql = "SELECT\n" + "\tfo.BUSINESS_FORM_CODE,\n" + "\tfo.AGENCY_NAME tenantName,\n" |
| | | + "\tGOODS_NAME templateName,\n" + "\tpm.BASE_GOODS_MODELS_NAME baseModelName,\n" + "\tcounts num,\n" |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 通过调拨单查询出库单id |
| | | * |
| | | * @param transBusinessId |
| | | * @return |
| | | */ |
| | | private static String QUEYR_ID_BY_TRANSFERID = |
| | | "select id from L_WH_FORM_OUTPUT where TRANS_BUSINESS_ID =:transBusinessId limit 1"; |
| | | |
| | | @Override |
| | | public Long queyrIdByTransferId(Long transBusinessId) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("transBusinessId", transBusinessId); |
| | | List<WhFormOutput> whFormOutputs = select(QUEYR_ID_BY_TRANSFERID, map, new WhFormOutput()); |
| | | if (CollectionUtils.isEmpty(whFormOutputs)) { |
| | | return null; |
| | | } |
| | | return whFormOutputs.get(0).getId(); |
| | | } |
| | | |
| | | } |
| | |
| | | LWhFormScrappedGoods scrappedGoods = new LWhFormScrappedGoods(); |
| | | scrappedGoods.setId(IdUtil.generateId()); |
| | | // 根据物品型号查询物品库存 |
| | | int goodsNum = this.lWhGoodsService.queryGoodsModelNum(0, warehouseId, |
| | | scrappedGoods.getBaseGoodsModelsId(), 1, null); |
| | | int goodsNum = |
| | | lWhGoodsService.queryGoodsModelNum(0, warehouseId, scrappedGoods.getBaseGoodsModelsId(), 1, null); |
| | | if (params.getCounts() > goodsNum) { |
| | | log.error("报废数量大于库存数量"); |
| | | return 0; |
| | |
| | | scrappedGoods.setBaseGoodsModelsName(baseGoodsModels.getModelName()); |
| | | scrappedGoods.setUnit(baseGoodsModels.getUnit()); |
| | | } |
| | | |
| | | // 通过型号id查询该型号所有商品的总金额 |
| | | // GoodsModelCountDTO goodsModelCountDTO = |
| | | // lWhGoodsService.queryGoodsAmount(baseGoodsModelsId, GoodsStatesType.SCRAP.getValue()); |
| | | // scrappedGoods.setTotalAmount(goodsModelCountDTO.getAmount()); |
| | | scrappedGoodsList.add(scrappedGoods); |
| | | } |
| | | int flag2 = this.scrappedGoodsService.insertBatch(scrappedGoodsList); |
| | |
| | | import com.consum.base.service.BaseWarehouseManagerService; |
| | | import com.consum.base.service.BaseWarehouseService; |
| | | import com.consum.base.service.FinSysTenantServiceImpl; |
| | | import com.consum.base.service.LWhFormOutputServiceImpl; |
| | | import com.consum.base.service.LWhFormOutputService; |
| | | import com.consum.base.service.LWhFormTransferService; |
| | | import com.consum.base.service.LWhGoodsService; |
| | | import com.consum.base.service.LWhProcureModelService; |
| | |
| | | private LWhGoodsService lWhGoodsService; |
| | | @Autowired |
| | | private LWhProcureModelService lWhProcureModelService; |
| | | @Autowired |
| | | private LWhFormOutputServiceImpl lWhFormOutputService; |
| | | @Autowired |
| | | private BaseGoodsModelsServiceImpl baseGoodsModelsService; |
| | | @Autowired |
| | |
| | | if (businessType == 0) { |
| | | lWhProcureModel.setBusinessType(2); |
| | | // 根据物品型号查询物品库存 |
| | | int goodsNum = this.lWhGoodsService.queryGoodsModelNum(0, warehouseId, baseGoodsModelsId, 1, null); |
| | | int goodsNum = lWhGoodsService.queryGoodsModelNum(0, warehouseId, baseGoodsModelsId, 1, null); |
| | | lWhProcureModel.setWorehouseCount(goodsNum); |
| | | } |
| | | if (businessType == 1) { |
| | |
| | | + "WHERE pm.BUSINESS_ID =:id GROUP BY bgt.id "; |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("id", result.getId()); |
| | | List<Map<String, Object>> procureModelList = lWhFormOutputService.select(sql, paramMap, new MapperUtil()); |
| | | List<Map<String, Object>> procureModelList = this.select(sql, paramMap, new MapperUtil()); |
| | | |
| | | String queryRecord = |
| | | "SELECT * FROM l_wh_procure_model_user_record where TRANS_BUSINESS_ID = :id order by DEAL_TIME desc limit 1"; |
| | |
| | | Map<String, Object> goodsModelParamMap = new HashMap<>(); |
| | | goodsModelParamMap.put("id", result.getId()); |
| | | goodsModelParamMap.put("baseGoodsTemplateId", baseGoodsTemplateId); |
| | | List<Map<String, Object>> modelList = |
| | | lWhFormOutputService.select(sql2, goodsModelParamMap, new MapperUtil()); |
| | | List<Map<String, Object>> modelList = this.select(sql2, goodsModelParamMap, new MapperUtil()); |
| | | modelList.forEach(item -> { |
| | | GoodsModelVO goodsModelVO = MapUtils.convertMapToObj(item, GoodsModelVO.class); |
| | | Integer businessType = result.getBusinessType(); |
New file |
| | |
| | | package com.consum.base.service.impl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.consum.base.core.utils.MapUtils; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.consum.base.pojo.dto.GoodsModelCountDTO; |
| | | import com.consum.base.service.LWhGoodsService; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.jdbc.service.BaseServiceImpl; |
| | | |
| | | /** |
| | | * @ClassName LWhGoodsService |
| | | * @Date 2023/10/24 |
| | | * @Description |
| | | * @Version 1.0 |
| | | **/ |
| | | @Service |
| | | public class LWhGoodsServiceImpl extends BaseServiceImpl implements LWhGoodsService { |
| | | |
| | | /** |
| | | * @param warehouseType 仓库类型0机构1部门 |
| | | * @param warehouseId 所属仓库仓库编号 |
| | | * @param baseGoodsModelsId 规格型号编号 |
| | | * @param states (0=在途调拨;1=入库未分发;2=已下发;3=报废) |
| | | * @param buyType 采购方式(1:集采;2=自采) |
| | | * @return 查询某个型号在仓库中的数量 |
| | | */ |
| | | private static String query_Goods_Model_Num = "SELECT COUNT(1) from L_WH_GOODS where 1=1"; |
| | | |
| | | @Override |
| | | public int queryGoodsModelNum(Integer warehouseType, Long warehouseId, Long baseGoodsModelsId, Integer states, |
| | | Integer buyType) { |
| | | StringBuilder sql = new StringBuilder(query_Goods_Model_Num); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | |
| | | if (warehouseType != null) { |
| | | sql.append(" and WAREHOUSE_TYPE=:warehouseType"); |
| | | paramts.put("warehouseType", warehouseType); |
| | | } |
| | | if (warehouseId != null) { |
| | | sql.append(" and WAREHOUSE_ID=:warehouseId"); |
| | | paramts.put("warehouseId", warehouseId); |
| | | } |
| | | if (baseGoodsModelsId != null) { |
| | | sql.append(" and BASE_GOODS_MODELS_ID=:baseGoodsModelsId"); |
| | | paramts.put("baseGoodsModelsId", baseGoodsModelsId); |
| | | } |
| | | if (states != null) { |
| | | sql.append(" and STATES=:states"); |
| | | paramts.put("states", states); |
| | | } |
| | | if (buyType != null) { |
| | | sql.append(" and BUY_TYPE=:buyType"); |
| | | paramts.put("buyType", buyType); |
| | | } |
| | | return queryForInt(sql.toString(), paramts); |
| | | } |
| | | |
| | | /** |
| | | * 出库时候,先入库的先出库,同时入库的,按价格高的先出库 |
| | | * |
| | | * @param warehouseId 所属仓库仓库编号 |
| | | * @param baseGoodsModelsId 规格型号编号 |
| | | * @param states 状态(0=在途调拨;1=入库未分发;2=已下发;3=报废) |
| | | * @param buyType 采购方式(1:集采;2=自采) |
| | | * @param goodsModelNum 取出的数量 |
| | | * @return |
| | | */ |
| | | private static String QUERY_OUT_GOODS_ID = "SELECT * FROM L_WH_GOODS WHERE 1=1"; |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryOutGoods(Integer warehouseType, Long warehouseId, Long baseGoodsModelsId, |
| | | Integer states, Integer buyType, Integer goodsModelNum) { |
| | | StringBuilder sql = new StringBuilder(QUERY_OUT_GOODS_ID); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | if (warehouseType != null) { |
| | | sql.append(" and WAREHOUSE_TYPE=:warehouseType"); |
| | | paramts.put("warehouseType", warehouseType); |
| | | } |
| | | if (warehouseId != null) { |
| | | sql.append(" and WAREHOUSE_ID=:warehouseId"); |
| | | paramts.put("warehouseId", warehouseId); |
| | | } |
| | | if (baseGoodsModelsId != null) { |
| | | sql.append(" and BASE_GOODS_MODELS_ID=:baseGoodsModelsId"); |
| | | paramts.put("baseGoodsModelsId", baseGoodsModelsId); |
| | | } |
| | | if (states != null) { |
| | | sql.append(" and STATES=:states"); |
| | | paramts.put("states", states); |
| | | } |
| | | if (buyType != null) { |
| | | sql.append(" and BUY_TYPE=:buyType"); |
| | | paramts.put("buyType", buyType); |
| | | } |
| | | return select(sql.append(" limit ").append(goodsModelNum).toString(), paramts); |
| | | } |
| | | |
| | | /** |
| | | * 出库时候,先入库的先出库,同时入库的,按价格高的先出库 |
| | | * |
| | | * @param warehouseId 所属仓库仓库编号 |
| | | * @param baseGoodsModelsId 规格型号编号 |
| | | * @param states 状态(0=在途调拨;1=入库未分发;2=已下发;3=报废) |
| | | * @param buyType 采购方式(1:集采;2=自采) |
| | | * @param goodsModelNum 取出的数量 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Long> queryOutGoodsId(Integer warehouseType, Long warehouseId, Long baseGoodsModelsId, Integer states, |
| | | Integer buyType, Integer goodsModelNum) { |
| | | List<Map<String, Object>> outGoods = |
| | | queryOutGoods(warehouseType, warehouseId, baseGoodsModelsId, states, buyType, goodsModelNum); |
| | | if (CollectionUtils.isEmpty(outGoods)) { |
| | | return null; |
| | | } |
| | | List<Long> whGoodsIds = outGoods.stream().map(map -> (Long)map.get("id")).collect(Collectors.toList()); |
| | | return whGoodsIds; |
| | | } |
| | | |
| | | private static String QUERY_GOODS_PRICE_BY_ID = "SELECT sum(PRICE)totalPrice from L_WH_GOODS goods where 1=1"; |
| | | |
| | | @Override |
| | | public long queryGoodsPriceById(List<Long> goodsIds) { |
| | | StringBuilder sql = new StringBuilder(QUERY_GOODS_PRICE_BY_ID); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(goodsIds)) { |
| | | sql.append(" and id in(:goodsIds)"); |
| | | paramts.put("goodsIds", goodsIds); |
| | | } |
| | | List<Map<String, Object>> map = this.select(sql.toString(), paramts); |
| | | if (CollectionUtils.isEmpty(map)) { |
| | | return 0; |
| | | } |
| | | BigDecimal totalPrice = (BigDecimal)map.get(0).get("totalPrice"); |
| | | return totalPrice.longValue(); |
| | | } |
| | | |
| | | /** |
| | | * 查询报废物品 默认优先报废最高价的物品 |
| | | * |
| | | * @param warehouseType |
| | | * @param warehouseId |
| | | * @param transBusinessId 调拨单号 |
| | | * @param nowUserName 使用人姓名 |
| | | * @param baseGoodsModelsId 物品型号 |
| | | * @param states 状态(0=在途调拨;1=入库未分发;2=已下发;3=报废 4 零星出库) |
| | | * @param goodsModelNum 取出的数量 |
| | | * @return |
| | | */ |
| | | |
| | | private static String QUERY_SCRAPPED_GOODS_PREFIX_1 = |
| | | "SELECT goods.id, goods.PRICE FROM L_WH_GOODS goods LEFT JOIN L_GOODS_USER_RECORD useRecord ON goods.id=useRecord.WH_GOODS_ID AND useRecord.LAST_RECORD=1 WHERE 1=1 "; |
| | | private static String QUERY_SCRAPPED_GOODS_PREFIX_2 = |
| | | " AND goods.id IN (SELECT lwgrd.WH_GOODS_ID FROM L_WAREHOUSE_FLOW flow LEFT JOIN L_WH_GOODS_RECORD lwgr ON lwgr.WAREHOUSE_FLOW_ID=flow.id LEFT JOIN L_WH_GOODS_RECORD_DETAILS lwgrd ON lwgrd.WH_GOODS_RECORD_ID=lwgr.id WHERE flow.THIS_TYPE=1 AND flow.BUSINESS_FORM_ID=:transBusinessId)"; |
| | | private static String QUERY_SCRAPPED_GOODS_PREFIX_2_MODEL_NOT_NULL = |
| | | " AND goods.id IN (SELECT lwgrd.WH_GOODS_ID FROM L_WAREHOUSE_FLOW flow LEFT JOIN L_WH_GOODS_RECORD lwgr ON lwgr.WAREHOUSE_FLOW_ID=flow.id LEFT JOIN L_WH_GOODS_RECORD_DETAILS lwgrd ON lwgrd.WH_GOODS_RECORD_ID=lwgr.id WHERE flow.THIS_TYPE=1 AND flow.BUSINESS_FORM_ID=:transBusinessId AND lwgr.BASE_GOODS_MODELS_ID = :lwgrGoodsModelId)"; |
| | | private static String QUERY_SCRAPPED_GOODS_END = " ORDER BY goods.PRICE DESC,goods.PROCURE_DATE ASC,goods.id"; |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryScrappedGoods(Integer warehouseType, Long warehouseId, Long transBusinessId, |
| | | String nowUserName, Long baseGoodsModelsId, Short states, Integer goodsModelNum) { |
| | | if (warehouseType == null) { |
| | | warehouseType = 0; |
| | | } |
| | | StringBuilder sql = new StringBuilder(QUERY_SCRAPPED_GOODS_PREFIX_1); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | if (warehouseType != null) { |
| | | sql.append(" AND goods.WAREHOUSE_TYPE=:warehouseType"); |
| | | paramts.put("warehouseType", warehouseType); |
| | | } |
| | | if (warehouseId != null) { |
| | | sql.append(" AND goods.WAREHOUSE_ID=:warehouseId"); |
| | | paramts.put("warehouseId", warehouseId); |
| | | } |
| | | if (StringUtils.isNotEmpty(nowUserName)) { |
| | | sql.append(" AND useRecord.NOW_USER_NAME=:nowUserName"); |
| | | paramts.put("nowUserName", nowUserName); |
| | | } |
| | | if (baseGoodsModelsId != null) { |
| | | sql.append(" AND goods.BASE_GOODS_MODELS_ID=:baseGoodsModelsId"); |
| | | paramts.put("baseGoodsModelsId", baseGoodsModelsId); |
| | | } |
| | | if (states != null) { |
| | | sql.append(" AND goods.STATES=:states"); |
| | | paramts.put("states", states); |
| | | } |
| | | if (transBusinessId != null) { |
| | | if (baseGoodsModelsId != null) { |
| | | sql.append(QUERY_SCRAPPED_GOODS_PREFIX_2_MODEL_NOT_NULL); |
| | | paramts.put("transBusinessId", transBusinessId); |
| | | paramts.put("lwgrGoodsModelId", baseGoodsModelsId); |
| | | } else { |
| | | sql.append(QUERY_SCRAPPED_GOODS_PREFIX_2); |
| | | paramts.put("transBusinessId", transBusinessId); |
| | | } |
| | | } |
| | | sql.append(QUERY_SCRAPPED_GOODS_END); |
| | | if (goodsModelNum != null) { |
| | | sql.append(" limit ").append(goodsModelNum); |
| | | } |
| | | return select(sql.toString(), paramts); |
| | | } |
| | | |
| | | /** |
| | | * 查询报废物品 默认优先报废最高价的物品 |
| | | * |
| | | * @param warehouseType |
| | | * @param warehouseId |
| | | * @param transBusinessId 调拨单号 |
| | | * @param nowUserName 使用人姓名 |
| | | * @param baseGoodsModelsId 物品型号 |
| | | * @param states 状态(0=在途调拨;1=入库未分发;2=已下发;3=报废 4 零星出库) |
| | | * @param goodsModelNum 取出的数量 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Long> queryScrappedGoodsIds(Integer warehouseType, Long warehouseId, Long transBusinessId, |
| | | String nowUserName, Long baseGoodsModelsId, Short states, Integer goodsModelNum) { |
| | | List<Map<String, Object>> outGoods = queryScrappedGoods(warehouseType, warehouseId, transBusinessId, |
| | | nowUserName, baseGoodsModelsId, states, goodsModelNum); |
| | | if (CollectionUtils.isEmpty(outGoods)) { |
| | | return null; |
| | | } |
| | | List<Long> whGoodsIds = outGoods.stream().map(map -> (Long)map.get("id")).collect(Collectors.toList()); |
| | | return whGoodsIds; |
| | | } |
| | | |
| | | /** |
| | | * 设置物品状态为调拨中 |
| | | * |
| | | * @param whGoods |
| | | * @param toWarehouseId |
| | | * @param toWarehouseName |
| | | * @return |
| | | */ |
| | | private static String MOD_GOODS_TRANSFERING_PREFIX = "update L_WH_GOODS set "; |
| | | |
| | | @Override |
| | | public int modGoodsTransfering(List<Long> whGoods, Integer warehouseType, Long toWarehouseId, |
| | | String toWarehouseName, Integer states) { |
| | | StringBuilder sql = new StringBuilder(MOD_GOODS_TRANSFERING_PREFIX); |
| | | ArrayList<Object> params = new ArrayList<>(); |
| | | if (warehouseType != null) { |
| | | sql.append(", WAREHOUSE_TYPE=?"); |
| | | params.add(warehouseType); |
| | | } |
| | | if (toWarehouseId != null) { |
| | | sql.append(", WAREHOUSE_ID=?"); |
| | | params.add(toWarehouseId); |
| | | } |
| | | if (toWarehouseName != null) { |
| | | sql.append(", WAREHOUSE_NAME=?"); |
| | | params.add(toWarehouseName); |
| | | } |
| | | if (states != null) { |
| | | sql.append(", STATES=?"); |
| | | params.add(states); |
| | | } |
| | | sql.deleteCharAt(22); |
| | | sql.append(" where id in(").append(StringUtils.join(whGoods, ",")).append(")"); |
| | | return update(sql.toString(), params.toArray()); |
| | | } |
| | | |
| | | private static String GOODS_NUM_PRICE = |
| | | "SELECT t.tenantId,count(id) total_Num,count(CASE WHEN STATES=2 THEN 1 END) xia_fa_num,IFNULL(round(sum(PRICE)/1000000,2),0) total_price,IFNULL(ROUND(count(CASE WHEN STATES=2 THEN 1 END)/count(id),4),0)*100 AS zhan_you_percent,count(CASE COST_TYPE WHEN 1 THEN 1 END) a_total_Num,count(CASE COST_TYPE WHEN 2 THEN 1 END) b_total_Num,count(CASE COST_TYPE WHEN 3 THEN 1 END) c_total_Num,IFNULL( round( sum( CASE COST_TYPE WHEN 1 THEN PRICE END )/ 1000000, 2 ), 0 ) a_total_price,IFNULL( round( sum( CASE COST_TYPE WHEN 2 THEN PRICE END )/ 1000000, 2 ), 0 ) b_total_price,IFNULL( round( sum( CASE COST_TYPE WHEN 3 THEN PRICE END )/ 1000000, 2 ), 0 ) c_total_price FROM (SELECT tCangKu.tenantId,tKuCun.id,tKuCun.STATES,tKuCun.COST_TYPE,tKuCun.price FROM (SELECT tenant.id tenantId,tenant.NAME AS org_name,ware.*FROM fin_sys_tenant tenant RIGHT JOIN ( SELECT 0 WAREHOUSE_TYPE,id,AGENCY_ID,WAREHOUSE_NAME FROM BASE_WAREHOUSE UNION ALL SELECT 1 WAREHOUSE_TYPE,id,TENANT_ID AGENCY_ID,`NAME` WAREHOUSE_NAME FROM fin_sys_tenant_department) ware ON tenant.id=ware.AGENCY_ID WHERE 1=1 "; |
| | | private static String GOODS_NUM_PRICE_END = |
| | | ") tCangKu LEFT JOIN L_WH_GOODS tKuCun ON tCangKu.WAREHOUSE_TYPE=tKuCun.WAREHOUSE_TYPE AND tCangKu.id=tKuCun.WAREHOUSE_ID AND tKuCun.STATES BETWEEN 1 AND 2 where tKuCun.id is not null) t GROUP BY t.tenantId"; |
| | | |
| | | // 按机构统计物品价值、数量/金额等 |
| | | @Override |
| | | public List<Map<String, Object>> getGoodsNumPrice(Long agencyId) { |
| | | StringBuilder sql = new StringBuilder(GOODS_NUM_PRICE); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | sql.append(" and tenant.id=:agencyId"); |
| | | paramts.put("agencyId", agencyId); |
| | | return select(sql.append(GOODS_NUM_PRICE_END).toString(), paramts, new MapperUtil()); |
| | | } |
| | | |
| | | private static String GET_GOODS_NUM_BY_MONTH = |
| | | "SELECT monthT.month_Num,IFNULL(datat.total_Num,0) total_Num,IFNULL(datat.add_total_Num,0) add_total_Num,IFNULL(datat.reduce_total_Num,0) reduce_total_Num FROM (SELECT monthT.month_Num FROM (SELECT ( SELECT 1) month_Num UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10 UNION SELECT 11 UNION SELECT 12) monthT) monthT LEFT JOIN ( SELECT t.tenantId,count(t.THIS_COUNT) total_Num,count(CASE t.THIS_TYPE WHEN 1 THEN t.THIS_COUNT END) add_total_Num,count(CASE t.THIS_TYPE WHEN 2 THEN t.THIS_COUNT END) reduce_total_Num,SUBSTR(DEAL_TIME,5,2) data_month FROM ( SELECT tCangKu.tenantId,tKuCun.id,tKuCun.THIS_TYPE,tKuCun.THIS_COUNT,tKuCun.DEAL_TIME FROM (SELECT tenant.id tenantId,tenant.NAME AS org_name,ware.*FROM fin_sys_tenant tenant RIGHT JOIN ( SELECT 0 WAREHOUSE_TYPE,id,AGENCY_ID,WAREHOUSE_NAME FROM BASE_WAREHOUSE UNION ALL SELECT 1 WAREHOUSE_TYPE,id,TENANT_ID AGENCY_ID,`NAME` WAREHOUSE_NAME FROM fin_sys_tenant_department) ware ON tenant.id=ware.AGENCY_ID WHERE 1=1 "; |
| | | private static String GET_GOODS_NUM_BY_MONTH_END = |
| | | ")tCangKu LEFT JOIN L_WH_GOODS_RECORD tKuCun ON tCangKu.WAREHOUSE_TYPE=tKuCun.WAREHOUSE_TYPE AND tCangKu.id=tKuCun.WAREHOUSE_ID and tKuCun.DEAL_TIME between cast(CONCAT(DATE_FORMAT(NOW(), '%Y'),'1231240000') as UNSIGNED) and cast(CONCAT(DATE_FORMAT(NOW(), '%Y'),'0101000000') as UNSIGNED)) t GROUP BY t.tenantId,SUBSTR(DEAL_TIME,5,2)) datat ON datat.data_month=monthT.month_Num ORDER BY monthT.month_Num ASC"; |
| | | |
| | | // 按机构统计物品价值、数量/金额等 |
| | | @Override |
| | | public List<Map<String, Object>> getGoodsNumByMonth(Long agencyId) { |
| | | StringBuilder sql = new StringBuilder(GET_GOODS_NUM_BY_MONTH); |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | sql.append(" and tenant.id=:agencyId"); |
| | | paramts.put("agencyId", agencyId); |
| | | return select(sql.append(GET_GOODS_NUM_BY_MONTH_END).toString(), paramts, new MapperUtil()); |
| | | } |
| | | |
| | | @Override |
| | | public GoodsModelCountDTO queryGoodsAmount(Long baseGoodsModelsId, Integer type) { |
| | | StringBuilder sql = new StringBuilder( |
| | | "SELECT sum(PRICE) amount from L_WH_GOODS where base_goods_models_id =:baseGoodsModelsId and states =:type"); |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("baseGoodsModelsId", baseGoodsModelsId); |
| | | param.put("type", type); |
| | | List<Map<String, Object>> result = this.select(sql.toString(), param); |
| | | if (!CollectionUtils.isEmpty(result)) { |
| | | List<GoodsModelCountDTO> goodsModelCount = Lists.newArrayList(); |
| | | for (Map<String, Object> item : result) { |
| | | GoodsModelCountDTO goodsModelCountDTO = MapUtils.convertMapToObj(item, GoodsModelCountDTO.class); |
| | | goodsModelCount.add(goodsModelCountDTO); |
| | | } |
| | | return goodsModelCount.get(0); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | } |
| | |
| | | @JsonIgnore |
| | | protected boolean isset_sort = false; |
| | | |
| | | private Integer totalAmount; |
| | | @JsonIgnore |
| | | protected boolean isset_totalAmount = false; |
| | | |
| | | /** |
| | | * 默认构造函数 |
| | | */ |
| | |
| | | return this.sort == null; |
| | | } |
| | | |
| | | public Integer getTotalAmount() { |
| | | return this.totalAmount; |
| | | } |
| | | |
| | | public void setTotalAmount(Integer totalAmount) { |
| | | this.totalAmount = totalAmount; |
| | | this.isset_totalAmount = true; |
| | | } |
| | | |
| | | @JsonIgnore |
| | | public boolean isEmptyTotalAmount() { |
| | | return this.totalAmount == null; |
| | | } |
| | | |
| | | /** |
| | | * 重写 toString() 方法 |
| | | */ |
| | |
| | | .append("transBusinessId=").append(this.transBusinessId) |
| | | .append("userName=").append(this.userName) |
| | | .append("sort=").append(this.sort) |
| | | .append("totalAmount=").append(this.totalAmount) |
| | | .toString(); |
| | | } |
| | | |
| | |
| | | if (this.isset_sort) { |
| | | l_wh_form_scrapped_goods.setSort(this.getSort()); |
| | | } |
| | | if (this.isset_totalAmount) { |
| | | l_wh_form_scrapped_goods.setTotalAmount(this.getTotalAmount()); |
| | | } |
| | | return l_wh_form_scrapped_goods; |
| | | } |
| | | } |
| | |
| | | package com.consum.model.po; |
| | | |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | import java.util.Map; |
| | | |
| | | import org.springframework.jdbc.core.RowMapper; |
| | | |
| | | import com.walker.jdbc.BaseMapper; |
| | | import com.walker.jdbc.ResultSetUtils; |
| | | import com.walker.jdbc.SqlAndParameters; |
| | |
| | | import com.walker.jdbc.sqlgen.InsertBuilder; |
| | | import com.walker.jdbc.sqlgen.SelectBuilder; |
| | | import com.walker.jdbc.sqlgen.UpdateBuilder; |
| | | import com.walker.jdbc.util.StringUtils; |
| | | |
| | | import org.springframework.jdbc.core.RowMapper; |
| | | |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 表名:L_WH_FORM_SCRAPPED_GOODS * |
| | |
| | | public static final String TransBusinessId = "trans_business_id"; |
| | | public static final String UserName = "user_name"; |
| | | public static final String Sort = "sort"; |
| | | public static final String TotalAmount = "total_amount"; |
| | | |
| | | /** |
| | | * 默认构造函数 |
| | |
| | | } |
| | | if (lWhFormScrappedGoods.isset_sort) { |
| | | this.setSort(lWhFormScrappedGoods.getSort()); |
| | | } |
| | | if (lWhFormScrappedGoods.isset_totalAmount) { |
| | | this.setTotalAmount(lWhFormScrappedGoods.getTotalAmount()); |
| | | } |
| | | // 去掉,2022-09-07 |
| | | // this.setDatabaseName_(l_wh_form_scrapped_goods.getDatabaseName_()); |
| | |
| | | ib.set(TransBusinessId, this.getTransBusinessId(), this.isset_transBusinessId); |
| | | ib.set(UserName, this.getUserName(), this.isset_userName); |
| | | ib.set(Sort, this.getSort(), this.isset_sort); |
| | | ib.set(TotalAmount, this.getTotalAmount(), this.isset_totalAmount); |
| | | return ib.genMapSql(); |
| | | } |
| | | |
| | |
| | | ub.set(TransBusinessId, this.getTransBusinessId(), this.isset_transBusinessId); |
| | | ub.set(UserName, this.getUserName(), this.isset_userName); |
| | | ub.set(Sort, this.getSort(), this.isset_sort); |
| | | ub.set(TotalAmount, this.getTotalAmount(), this.isset_totalAmount); |
| | | ub.where(this.getPkName_(), this.getPkValue_()); |
| | | return ub.genMapSql(); |
| | | } |
| | |
| | | ub.set(TransBusinessId, this.getTransBusinessId(), this.isset_transBusinessId); |
| | | ub.set(UserName, this.getUserName(), this.isset_userName); |
| | | ub.set(Sort, this.getSort(), this.isset_sort); |
| | | ub.set(TotalAmount, this.getTotalAmount(), this.isset_totalAmount); |
| | | return ub.genMapSql(where, parameters); |
| | | } |
| | | |
| | |
| | | ub.set(TransBusinessId, this.getTransBusinessId(), this.isset_transBusinessId); |
| | | ub.set(UserName, this.getUserName(), this.isset_userName); |
| | | ub.set(Sort, this.getSort(), this.isset_sort); |
| | | ub.set(TotalAmount, this.getTotalAmount(), this.isset_totalAmount); |
| | | return ub.genArraySql(where, parameters); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public SqlAndParameters<Map<String, Object>> getSelectSql_(String where, Map<String, Object> parameters) { |
| | | return new SqlAndParameters<>("select id, counts, scrapped_code, scrapped_name, beiz, form_scrapped_id, base_goods_template_id, goods_template_name, unit, base_goods_models_id, base_goods_models_name, trans_business_id, user_name, sort from " + this.getTableName_() + " " + where, parameters); |
| | | return new SqlAndParameters<>("select id, counts, scrapped_code, scrapped_name, beiz, form_scrapped_id, base_goods_template_id, goods_template_name, unit, base_goods_models_id, base_goods_models_name, trans_business_id, user_name, sort, total_amount from " + this.getTableName_() + " " + where, parameters); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public SqlAndParameters<Object[]> getSelectSql_(String where, Object[] parameters) { |
| | | return new SqlAndParameters<>("select id, counts, scrapped_code, scrapped_name, beiz, form_scrapped_id, base_goods_template_id, goods_template_name, unit, base_goods_models_id, base_goods_models_name, trans_business_id, user_name, sort from " + this.getTableName_() + " " + where, parameters); |
| | | return new SqlAndParameters<>("select id, counts, scrapped_code, scrapped_name, beiz, form_scrapped_id, base_goods_template_id, goods_template_name, unit, base_goods_models_id, base_goods_models_name, trans_business_id, user_name, sort, total_amount from " + this.getTableName_() + " " + where, parameters); |
| | | } |
| | | |
| | | /** |
| | |
| | | l_wh_form_scrapped_goods.setSort(rs.getLong(columnIndex)); |
| | | } |
| | | } |
| | | columnIndex = resultSetUtils.findColumn(rs, LWhFormScrappedGoods_mapper.TotalAmount); |
| | | if (columnIndex > 0) { |
| | | if (rs.getBigDecimal(columnIndex) == null) { |
| | | l_wh_form_scrapped_goods.setTotalAmount(null); |
| | | } else { |
| | | l_wh_form_scrapped_goods.setTotalAmount(rs.getInt(columnIndex)); |
| | | } |
| | | } |
| | | return l_wh_form_scrapped_goods; |
| | | } |
| | | } |