Commit b413bd27 by 赵剑炜

Merge branch 'develop' of http://gitlab.sothing.top/843502640/jyzb_platformV2 into develop-zhaojw

# Conflicts:
#	jyzb-biz/src/main/resources/mapper/InventorySummaryMapper.xml
parents 66bfb3f0 7952b8c4
...@@ -1403,7 +1403,7 @@ Was expecting one of: ...@@ -1403,7 +1403,7 @@ Was expecting one of:
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
at com.sun.proxy.$Proxy273.GetDetailByTerms(Unknown Source) at com.sun.proxy.$Proxy273.s(Unknown Source)
at com.junmp.jyzb.service.impl.InventoryServiceImpl.GetDetailByTerms(InventoryServiceImpl.java:305) at com.junmp.jyzb.service.impl.InventoryServiceImpl.GetDetailByTerms(InventoryServiceImpl.java:305)
at com.junmp.jyzb.service.impl.InventoryServiceImpl$$FastClassBySpringCGLIB$$43c51e0c.invoke(<generated>) at com.junmp.jyzb.service.impl.InventoryServiceImpl$$FastClassBySpringCGLIB$$43c51e0c.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -117,5 +117,6 @@ public class LogDetailReq { ...@@ -117,5 +117,6 @@ public class LogDetailReq {
private String userName; private String userName;
private Long orgId; private Long orgId;
private Integer property;
} }
package com.junmp.jyzb.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.junmp.jyzb.entity.Inventory;
import com.junmp.jyzb.entity.InventorySummary;
import com.junmp.jyzb.service.EquipmentTypeService;
import com.junmp.jyzb.service.InventoryService;
import com.junmp.jyzb.service.InventorySummaryService;
import com.junmp.v2.common.bean.response.ApiRes;
import com.junmp.v2.db.api.factory.PageFactory;
import com.junmp.v2.dict.entity.SysDictItem;
import com.junmp.v2.dict.service.SysDictItemService;
import com.junmp.v2.message.api.MessageApi;
import com.junmp.v2.message.api.bean.req.MessageReq;
import com.junmp.v2.message.api.bean.req.MessageSendReq;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@Api("消息推送")
@RequestMapping("/MessageSend")
@Slf4j
public class MessageSendController {
@Resource
private InventoryService inventoryService;
@Resource
private InventorySummaryService inventorySummaryService;
@Resource
private EquipmentTypeService equipmentTypeService;
@Resource
private MessageApi messageApi;
@Resource
private SysDictItemService sysDictItemService;
// MessageSendReq sendReq = new MessageSendReq();
// sendReq.setSendUserId("1000");
// sendReq.setReceiveUserIds(userIds);
// sendReq.setMsgTitle(msgtTitle);
// sendReq.setBizType(bizType);
// sendReq.setMsgContent(msgContent);
// sendReq.setPriority("0");
// sendReq.setSendTime(DateTime.now());
// messageApi.sendMessage(sendReq);
// messageApi.queryCount(new MessageReq());
// /*推送发送未读数量*/
// for(Long userId :userIdList){
// MessageReq req1 = new MessageReq();
// req1.setReadFlag(0);
// req1.setReceiveUserId(userId);
// Integer count1 = messageApi.queryCount(req1);
// messageApi.pushMsgToUser(String.valueOf(userId),count1);
//消息推送场景1:物资低于物资阈值
// @PostMapping("/aaa")
// public ApiRes<Boolean> action1() {
//获取装备信息汇总,并且判断装备的汇总数量是否低于装备阈值,如果低于装备阈值,则进行消息提醒
//所有待判断的物资
// LambdaQueryWrapper<InventorySummary> wrapper = new LambdaQueryWrapper<InventorySummary>()
// .eq(InventorySummary::getLocationType, 0);
// //分页参数
// int pageSize=1000;
// int currentPage=1;
// //获取装备的所有库存数量
// long termCount= inventorySummaryService.count(wrapper);
// List<InventorySummary> list=new ArrayList<>();
// if (termCount>0) {
// // 分页查询
// while ((currentPage - 1) * pageSize < termCount) {
// List<InventorySummary> inventorySummaryList = processPageData1(currentPage, pageSize);
// currentPage++;
// list.addAll(inventorySummaryList);
// }
// }
// //超期物资查询出来之后,将超期物资进行消息推送提醒
// //直接对list进行处理操作推送消息即可
// for (InventorySummary inventorySummary:list) {
// MessageSendReq sendReq = new MessageSendReq();
// sendReq.setSendUserId("1000");
// sendReq.setReceiveUserIds("1000");
// sendReq.setMsgTitle("物资低于阈值");
// //设置业务类型
// SysDictItem one = sysDictItemService.getOne(new LambdaQueryWrapper<SysDictItem>()
// .eq(SysDictItem::getDictItemId, "1698969902300176385"));
// sendReq.setBizType(one.getItemValue());
// sendReq.setMsgContent(inventorySummary.getLocationName()+"仓库下的"+inventorySummary.getTypeName()+",号型为:"+inventorySummary.getSizeName()+"的物资低于阈值");
// sendReq.setPriority("0");
// sendReq.setSendTime(DateTime.now());
// messageApi.sendMessage(sendReq);
// }
// messageApi.queryCount(new MessageReq());
// /*推送发送未读数量*/
// List<Long> userIdList=new ArrayList<>();
// userIdList.add(1000L);
// for(Long userId :userIdList){
// MessageReq req1 = new MessageReq();
// req1.setReadFlag(0);
// req1.setReceiveUserId(userId);
// Integer count1 = messageApi.queryCount(req1);
// messageApi.pushMsgToUser(String.valueOf(userId),count1);
// }
// return ApiRes.success(true);
// }
// // 处理每页数据
// private List<InventorySummary> processPageData1(long pageSize, long currentPage) {
// //得到全局默认值(随机处理数据表中的一条数据为默认值)
// Integer threshold = equipmentTypeService.getById(100001).getThreshold();
// //查询inventory_summary表中的threshold字段是否存在值,
// // 如果存在则用summary表中的字段进行比较物资阈值,如果不存在则默认使用全局物资阈值进行比较
// LambdaQueryWrapper<InventorySummary> wrapper = new LambdaQueryWrapper<InventorySummary>()
// .eq(InventorySummary::getLocationType, 0);
// Page<InventorySummary> page = inventorySummaryService.page(PageFactory.getDefaultPage(pageSize, currentPage),wrapper);
// List<InventorySummary> records = page.getRecords();
// //使用自定义物资阈值进行比较
// List<InventorySummary> collect1 = records.stream()
// .filter(data -> ObjectUtil.isNotNull(data.getThreshold()))
// .filter(data -> data.getNumber() <= data.getThreshold())
// .collect(Collectors.toList());
// //使用全局物资阈值进行比较
// List<InventorySummary> collect2 = records.stream()
// .filter(data -> data.getNumber() <= threshold && ObjectUtil.isNull(data.getThreshold()))
// .collect(Collectors.toList());
// //将数据存储到一个list中
// List<InventorySummary> inventorySummaryList=new ArrayList<>();
// inventorySummaryList.addAll(collect1);
// inventorySummaryList.addAll(collect2);
// return inventorySummaryList;
// }
//消息推送场景2:物资超期
//消息推送场景3:过质保期
@PostMapping("/ccc")
public void action3() {
// LambdaQueryWrapper<Inventory> wrapper = new LambdaQueryWrapper<>();
// // 分页参数
// int pageSize = 1000; // 每页记录数,可以根据需求调整
// int currentPage = 1; // 当前页数
//
// //所有待判断的物资
// wrapper.eq( Inventory::getTermState, 0);
// //获取未超期的物资数量(并且他的state不是销毁状态)
// long termCount= inventoryService.count(wrapper);
// List<Inventory> list=new ArrayList<>();
// if (termCount>0) {
// // 分页查询
// while ((currentPage - 1) * pageSize < termCount) {
// List<Inventory> inventoryList = processPageData3(currentPage, pageSize);
// currentPage++;
// list.addAll(inventoryList);
// }
// }
// System.out.println(list);
// //超期物资查询出来之后,将超期物资进行消息推送提醒
// //直接对list进行处理操作推送消息即可
}
// 处理每页数据
private List<Inventory> processPageData3(long pageSize, long currentPage)
{
LocalDate localdate =LocalDate.now();
// 使用LambdaQueryWrapper构建查询条件
LambdaQueryWrapper<Inventory> wrapper = Wrappers.lambdaQuery();
wrapper.eq( Inventory::getTermState, 0);
//如果 生产日期 < 当前日期减去质保数,表示该装备已经超过质保期
wrapper.apply("production_date <= DATE_SUB({0}, INTERVAL warranty_period DAY)", "1970-03-01 00:00:00");
//获取过质保期的物资信息
List<Inventory> page= inventoryService.page(PageFactory.getDefaultPage(pageSize,currentPage),wrapper).getRecords();
page.forEach(o->o.setTermState(1));
inventoryService.saveOrUpdateBatch(page);
return page;
}
}
...@@ -153,12 +153,18 @@ public class PublicController { ...@@ -153,12 +153,18 @@ public class PublicController {
} }
@PostMapping(path = "/updateMessage",name = "更新消息#logType30") @PostMapping(path = "/updateMessage",name = "更新消息#logType=30")
@ApiOperation("更新消息") @ApiOperation("更新消息")
public ApiRes<Boolean> updateMessage(@RequestBody MessageReq req){ public ApiRes<Boolean> updateMessage(@RequestBody MessageReq req){
return ApiRes.success(publicService.updateMessage(req)); return ApiRes.success(publicService.updateMessage(req));
} }
@PostMapping(path = "/setReadMessage",name = "将消息设置为已读状态#logType=30")
@ApiOperation("将消息设置为已读状态")
public ApiRes<Boolean> setReadMessage(@RequestBody MessageReq req){
return ApiRes.success(publicService.setReadMessage(req));
}
@PostMapping("/aaa") @PostMapping("/aaa")
public ApiRes<List<Object>> aaa(@RequestBody OrderMainReq req){ public ApiRes<List<Object>> aaa(@RequestBody OrderMainReq req){
......
...@@ -18,4 +18,5 @@ public interface PublicService { ...@@ -18,4 +18,5 @@ public interface PublicService {
boolean updateMessage(MessageReq req); boolean updateMessage(MessageReq req);
boolean setReadMessage(MessageReq req);
} }
...@@ -312,237 +312,10 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -312,237 +312,10 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
page1.setTotal(size); page1.setTotal(size);
return PageResultFactory.createPageResult(page1); return PageResultFactory.createPageResult(page1);
} }
//批量进行调整
// @Override
// @Transactional(rollbackFor = Exception.class)
// public boolean BatchEditingInvsInfo(BatchEditingInvsReq req) {
// //查询inventory表中数据,对响应数据进行修改
// //判断是对整一类的装备进行修改还是说对个别几个装备进行批量修改
//// if (req.getInventoryIdList().size()!=0){
// List<InventorySummary> delList=new ArrayList<>();
// PubOrg pubOrg = pubOrgService.PubOrgExist(req.getOrgId());
// int size = req.getInventoryIdList().size();
// List<Object[]> searchItem=new ArrayList<>();
// if (req.getPrice().compareTo(req.getOriginalPrice())!=0){
// Object[] item=new Object[]{req.getOrgId(),req.getLocationId(),req.getTypeId(),req.getSizeId(),req.getPrice()};
// Object[] item1=new Object[]{req.getOrgId(),req.getLocationId(),req.getTypeId(),req.getSizeId(),req.getOriginalPrice()};
// searchItem.add(item);
// searchItem.add(item1);
// List<InventorySummary> inventorySummaryList = inventorySummaryMapper.selectSumByItems(searchItem);
// if (inventorySummaryList.size()==1){//等于1表示他修改后的单价的汇总信息没有,需要新增一条
// InventorySummary is = inventorySummaryList.get(0);
// is.setStockNumber(Math.max(is.getStockNumber()-size,0));
// is.setNumber(Math.max(is.getNumber()-size,0));
// is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber())));
// if (is.getNumber()==0 && is.getStockNumber()==0 && is.getOutboundNumber()==0 && is.getDestructionNumber()==0){
// delList.add(is);
// }
// //新增一条数据
// InventorySummary inventorySummary = new InventorySummary();
// BeanPlusUtil.copyProperties(req,inventorySummary);
// inventorySummary.setValuekey(pubOrg.getOrgCode()+req.getLocationId()+req.getTypeId()+req.getSizeId()+req.getPrice());
// inventorySummary.setOrgName(pubOrg.getOrgName());
// inventorySummary.setOrgCode(pubOrg.getOrgCode());
// inventorySummary.setNumber(size);
// inventorySummary.setStockNumber(size);
// inventorySummary.setOutboundNumber(0);
// inventorySummary.setLocationType("0");
// inventorySummary.setUnitPrice(req.getPrice());
// inventorySummary.setPrice(req.getOriginalPrice().multiply(BigDecimal.valueOf(size)));
// inventorySummary.setDestructionPrice(BigDecimal.ZERO);
// inventorySummary.setBrokenNumberPrice(BigDecimal.ZERO);
// inventorySummary.setExpireNumberPrice(BigDecimal.ZERO);
// inventorySummary.setBrokenNumber(0);
// inventorySummary.setExpireNumber(0);
// inventorySummary.setDestructionNumber(0);
// inventorySummary.setNearBrokenNumber(0);
// inventorySummaryService.save(inventorySummary);
// inventorySummaryService.updateBatchById(inventorySummaryList);
// }else {
// for (InventorySummary is:inventorySummaryList) {
// if (is.getUnitPrice().compareTo(req.getOriginalPrice())==0){//如果单价和修改前的价格一致
// is.setStockNumber(is.getStockNumber()-size);
// is.setNumber(is.getNumber()-size);
// is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber())));
// if (is.getNumber()==0 && is.getStockNumber()==0 && is.getOutboundNumber()==0 && is.getDestructionNumber()==0){
// delList.add(is);
// }
// }else {//单价和修改后的价格一致
// is.setStockNumber(is.getStockNumber()+size);
// is.setNumber(is.getNumber()+size);
// is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber())));
// }
// }
//
// inventorySummaryService.updateBatchById(inventorySummaryList);
// }
// if (CollectionUtil.isNotEmpty(delList)){
// inventorySummaryService.removeBatchByIds(delList);
// }
// }
//
// List<Inventory> list = list(new LambdaQueryWrapper<Inventory>().in(Inventory::getId, req.getInventoryIdList()));
// if (list.size()==0){
// throw new ServiceException(CabinetExceptionEnum.PARAMETER_ERROR);
// }else {
// //批量修改个别装备
//// List<Inventory> collect = list.stream().map(inventory -> {
//// BeanPlusUtil.copyProperties(req,inventory );
//// if (ObjectUtil.isNotNull(req.getShelfColumns()) && !req.getShelfColumns().toString().trim().isEmpty()
//// && ObjectUtil.isNotNull(req.getShelfRanges()) && !req.getShelfRanges().toString().trim().isEmpty()
//// && ObjectUtil.isNotNull(req.getShelfRows()) && !req.getShelfRows().toString().trim().isEmpty()) {
//// inventory.setShelfLocation(req.getShelfRanges() + "/" + req.getShelfColumns() + "/" + req.getShelfRows());
//// }
//// return inventory;
//// }).collect(Collectors.toList());
//// List<Inventory> list1 = list(new LambdaQueryWrapper<Inventory>().eq(Inventory::getId, list));
// List<Inventory> collect = list.stream().map(inventory -> {
// inventory.setWarrantyPeriod(req.getWarrantyPeriod());
// inventory.setMaintenancePeriod(req.getMaintenancePeriod());
// inventory.setPrice(req.getPrice());
// return inventory;
// }).collect(Collectors.toList());
// return updateBatchById(collect);
// }
//
//// }
//// else {
//// List<Inventory> list = list(createWrapper(req));
//// //直接将一类的数据进行修改
//// List<Inventory> collect = list.stream().map(inventory -> {
//// BeanPlusUtil.copyProperties(req, inventory);
//// if (ObjectUtil.isNotNull(req.getShelfColumns()) && !req.getShelfColumns().toString().trim().isEmpty()
//// && ObjectUtil.isNotNull(req.getShelfRanges()) && !req.getShelfRanges().toString().trim().isEmpty()
//// && ObjectUtil.isNotNull(req.getShelfRows()) && !req.getShelfRows().toString().trim().isEmpty()) {
//// inventory.setShelfLocation(req.getShelfRanges() + "/" + req.getShelfColumns() + "/" + req.getShelfRows());
//// }
//// return inventory;
//// }).collect(Collectors.toList());
//// return updateBatchById(collect);
//// }
// }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
// public boolean BatchEditingInvsInfo(BatchEditingInvsReq req) {
// //查询inventory表中数据,对响应数据进行修改
// //判断是对整一类的装备进行修改还是说对个别几个装备进行批量修改
//// if (req.getInventoryIdList().size()!=0){
// List<InventorySummary> delList=new ArrayList<>();
// PubOrg pubOrg = pubOrgService.PubOrgExist(req.getOrgId());
// int size = req.getInventoryIdList().size();
// List<Object[]> searchItem=new ArrayList<>();
// //(判断出库几条,入库几条)
// List<Inventory> list = list(new LambdaQueryWrapper<Inventory>().in(Inventory::getId, req.getInventoryIdList()));
//
// if (req.getPrice().compareTo(req.getOriginalPrice())!=0){
// int stockNum=0;
// int outBoundNum=0;
// for (Inventory inv:list) {
// if (inv.getLocationState().equals("in")){
// stockNum=stockNum+1;
// }else {
// outBoundNum=outBoundNum+1;
// }
//
// Object[] item=new Object[]{req.getOrgId(),inv.getLocationId(),req.getTypeId(),req.getSizeId(),req.getPrice()};
// Object[] item1=new Object[]{req.getOrgId(),inv.getLocationId(),req.getTypeId(),req.getSizeId(),req.getOriginalPrice()};
// searchItem.add(item);
// searchItem.add(item1);
// }
// List<InventorySummary> inventorySummaryList = inventorySummaryMapper.selectSumByItems(searchItem);
//
// if (inventorySummaryList.size()==1){//等于1表示他修改后的单价的汇总信息没有,需要新增一条
// InventorySummary is = inventorySummaryList.get(0);
// if (stockNum!=0){
// is.setStockNumber(is.getStockNumber()-stockNum);
// is.setNumber(is.getNumber()-stockNum);
// is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber())));
// }
// if (outBoundNum!=0){
// is.setOutboundNumber(is.getOutboundNumber()-outBoundNum);
// is.setNumber(is.getNumber()-outBoundNum);
// is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber())));
// }
// if (is.getNumber()==0 && is.getStockNumber()==0 && is.getOutboundNumber()==0 && is.getDestructionNumber()==0){
// delList.add(is);
// }
// //新增一条数据
// InventorySummary inventorySummary = new InventorySummary();
// BeanPlusUtil.copyProperties(req,inventorySummary);
// inventorySummary.setValuekey(pubOrg.getOrgCode()+req.getLocationId()+req.getTypeId()+req.getSizeId()+req.getPrice());
// inventorySummary.setOrgName(pubOrg.getOrgName());
// inventorySummary.setOrgCode(pubOrg.getOrgCode());
// inventorySummary.setNumber(size);
// inventorySummary.setStockNumber(size);
// inventorySummary.setOutboundNumber(0);
// inventorySummary.setLocationType("0");
// inventorySummary.setUnitPrice(req.getPrice());
// inventorySummary.setPrice(req.getOriginalPrice().multiply(BigDecimal.valueOf(size)));
// inventorySummary.setDestructionPrice(BigDecimal.ZERO);
// inventorySummary.setBrokenNumberPrice(BigDecimal.ZERO);
// inventorySummary.setExpireNumberPrice(BigDecimal.ZERO);
// inventorySummary.setUseNumber(0);
// inventorySummary.setBrokenNumber(0);
// inventorySummary.setExpireNumber(0);
// inventorySummary.setDestructionNumber(0);
// inventorySummary.setFixNumber(0);
// inventorySummary.setProperty(0);
// inventorySummaryService.save(inventorySummary);
// inventorySummaryService.updateBatchById(inventorySummaryList);
// }else {
// for (InventorySummary is:inventorySummaryList) {
// if (is.getUnitPrice().compareTo(req.getOriginalPrice())==0){//如果单价和修改前的价格一致
// if (stockNum!=0){
// is.setStockNumber(is.getStockNumber()-stockNum);
// is.setNumber(is.getNumber()-stockNum);
// is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber())));
// }
// if (outBoundNum!=0){
// is.setOutboundNumber(is.getOutboundNumber()-outBoundNum);
// is.setNumber(is.getNumber()-outBoundNum);
// is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber())));
// }
// }else {//单价和修改后的价格不一致
// if (stockNum!=0){
// is.setStockNumber(is.getStockNumber()+stockNum);
// is.setNumber(is.getNumber()+stockNum);
// is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber())));
// }
// if (outBoundNum!=0){
// is.setOutboundNumber(is.getOutboundNumber()+outBoundNum);
// is.setNumber(is.getNumber()+outBoundNum);
// is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber())));
// }
// }
//
// if (is.getNumber()==0 && is.getStockNumber()==0 && is.getOutboundNumber()==0 && is.getDestructionNumber()==0){
// delList.add(is);
// }
// }
//
// inventorySummaryService.updateBatchById(inventorySummaryList);
// }
// if (CollectionUtil.isNotEmpty(delList)){
// inventorySummaryService.removeBatchByIds(delList);
// }
// }
//
// if (list.size()==0){
// throw new ServiceException(CabinetExceptionEnum.PARAMETER_ERROR);
// }else {
// //批量修改个别装备
// List<Inventory> collect = list.stream().map(inventory -> {
// inventory.setWarrantyPeriod(req.getWarrantyPeriod());
// inventory.setMaintenancePeriod(req.getMaintenancePeriod());
// inventory.setPrice(req.getPrice());
// return inventory;
// }).collect(Collectors.toList());
// return updateBatchById(collect);
// }
//
// }
public boolean BatchEditingInvsInfo(BatchEditingInvsReq req) { public boolean BatchEditingInvsInfo(BatchEditingInvsReq req) {
//查询inventory表中数据,对响应数据进行修改 //查询inventory表中数据,对响应数据进行修改
//判断是对整一类的装备进行修改还是说对个别几个装备进行批量修改 //判断是对整一类的装备进行修改还是说对个别几个装备进行批量修改
...@@ -560,8 +333,8 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -560,8 +333,8 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
String key2 =inv.getLocationId()+inv.getTypeId()+inv.getSizeId()+req.getOriginalPrice()+inv.getProperty(); String key2 =inv.getLocationId()+inv.getTypeId()+inv.getSizeId()+req.getOriginalPrice()+inv.getProperty();
if (map.containsKey(key)){ if (map.containsKey(key)){
InventoryReq inventoryReq = map.get(key); InventoryReq inventoryReq = map.get(key);
inventoryReq.setStockNum(inventoryReq.getStockNum()+1); inventoryReq.setStockNum(inv.getLocationState().equals("in")?inventoryReq.getStockNum()+1:inventoryReq.getStockNum());
inventoryReq.setOutBoundNum(inventoryReq.getOutBoundNum()+1); inventoryReq.setOutBoundNum(inv.getLocationState().equals("out")?inventoryReq.getOutBoundNum()+1:inventoryReq.getOutBoundNum());
map.put(key,inventoryReq); map.put(key,inventoryReq);
}else { }else {
InventoryReq inventoryReq = new InventoryReq(); InventoryReq inventoryReq = new InventoryReq();
...@@ -577,8 +350,8 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -577,8 +350,8 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
} }
if (map.containsKey(key2)){ if (map.containsKey(key2)){
InventoryReq inventoryReq = map.get(key2); InventoryReq inventoryReq = map.get(key2);
inventoryReq.setStockNum(inventoryReq.getStockNum()+1); inventoryReq.setStockNum(inv.getLocationState().equals("in")?inventoryReq.getStockNum()+1:inventoryReq.getStockNum());
inventoryReq.setOutBoundNum(inventoryReq.getOutBoundNum()+1); inventoryReq.setOutBoundNum(inv.getLocationState().equals("out")?inventoryReq.getOutBoundNum()+1:inventoryReq.getOutBoundNum());
map.put(key2,inventoryReq); map.put(key2,inventoryReq);
}else { }else {
InventoryReq inventoryReq = new InventoryReq(); InventoryReq inventoryReq = new InventoryReq();
...@@ -594,69 +367,47 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -594,69 +367,47 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
} }
} }
List<InventoryReq> invList=new ArrayList<>();
for (String key:map.keySet()) { for (String key:map.keySet()) {
InventoryReq inv = map.get(key); InventoryReq inv = map.get(key);
Object[] item=new Object[]{req.getOrgId(),inv.getLocationId(),inv.getTypeId(),inv.getSizeId(),inv.getPrice(),inv.getProperty()}; Object[] item=new Object[]{req.getOrgId(),inv.getLocationId(),inv.getTypeId(),inv.getSizeId(),inv.getPrice(),inv.getProperty()};
searchItem.add(item); searchItem.add(item);
if (inv.getPrice().compareTo(req.getOriginalPrice())==0){
invList.add(inv);
}
} }
List<InventorySummary> inventorySummaryList = inventorySummaryMapper.selectSum(searchItem); List<InventorySummary> inventorySummaryList = inventorySummaryMapper.selectSum(searchItem);
for (InventoryReq inv:req.getInventoryList()) { for (String key:map.keySet() ) {
boolean flag=false; boolean flag=false;
InventoryReq inv = map.get(key);
for (InventorySummary is:inventorySummaryList) { for (InventorySummary is:inventorySummaryList) {
if (is.getUnitPrice().toString().substring(0, is.getUnitPrice().toString().length() - 3).equalsIgnoreCase(inv.getPrice().toString()) &&
if (is.getUnitPrice().toString().substring(0, is.getUnitPrice().toString().length() - 3).equals(req.getOriginalPrice().toString()) ){ req.getOriginalPrice().toString().equalsIgnoreCase(inv.getPrice().toString()) && inv.getLocationId().equals(is.getLocationId())){
is.setStockNumber(is.getStockNumber()-inv.getStockNum()); is.setStockNumber(is.getStockNumber()-inv.getStockNum());
is.setOutboundNumber(is.getOutboundNumber()-inv.getOutBoundNum()); is.setOutboundNumber(is.getOutboundNumber()-inv.getOutBoundNum());
is.setNumber(is.getNumber()-inv.getStockNum()-inv.getOutBoundNum()); is.setNumber(is.getNumber()-inv.getStockNum()-inv.getOutBoundNum());
is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber()))); is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber())));
}else { if (is.getNumber()==0 && is.getStockNumber()==0 && is.getOutboundNumber()==0 && is.getDestructionNumber()==0){
delList.add(is);
inventorySummaryList.remove(is);
}
flag=true;
break;
}
if (is.getUnitPrice().toString().substring(0, is.getUnitPrice().toString().length() - 3).equalsIgnoreCase(inv.getPrice().toString()) &&
req.getPrice().toString().equalsIgnoreCase(inv.getPrice().toString()) && inv.getLocationId().equals(is.getLocationId()))
{
is.setStockNumber(is.getStockNumber()+inv.getStockNum()); is.setStockNumber(is.getStockNumber()+inv.getStockNum());
is.setOutboundNumber(is.getOutboundNumber()+inv.getOutBoundNum()); is.setOutboundNumber(is.getOutboundNumber()+inv.getOutBoundNum());
is.setNumber(is.getNumber()+inv.getStockNum()+inv.getOutBoundNum()); is.setNumber(is.getNumber()+inv.getStockNum()+inv.getOutBoundNum());
is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber()))); is.setPrice(is.getUnitPrice().multiply(BigDecimal.valueOf(is.getNumber())));
}
flag=true; flag=true;
if (is.getNumber()==0 && is.getStockNumber()==0 && is.getOutboundNumber()==0 && is.getDestructionNumber()==0){
delList.add(is);
}
break; break;
} }
}
if (!flag){ if (!flag){
//新增一条数据 //新增一条数据
InventorySummary inventorySummary = new InventorySummary(); InventorySummary inventorySummary = addInvSum(inv,pubOrg);
inventorySummary.setOrgId(inv.getOrgId());
inventorySummary.setTypeId(inv.getTypeId());
inventorySummary.setTypeName(inv.getTypeName());
inventorySummary.setSizeId(inv.getSizeId());
inventorySummary.setSizeName(inv.getSizeName());
inventorySummary.setLocationId(inv.getLocationId());
inventorySummary.setLocationName(inv.getLocationName());
inventorySummary.setValuekey(pubOrg.getOrgCode()+inv.getLocationId()+inv.getTypeId()+inv.getSizeId()+inv.getPrice()+inv.getProperty());
inventorySummary.setOrgName(pubOrg.getOrgName());
inventorySummary.setLocationName(inv.getLocationName());
inventorySummary.setOrgCode(pubOrg.getOrgCode());
inventorySummary.setStockNumber(inv.getStockNum());
inventorySummary.setOutboundNumber(inv.getOutBoundNum());
inventorySummary.setNumber(inv.getStockNum()+inv.getOutBoundNum());
inventorySummary.setLocationType("0");
inventorySummary.setUnitPrice(inv.getPrice());
inventorySummary.setPrice(inv.getPrice().multiply(BigDecimal.valueOf(inventorySummary.getNumber())));
inventorySummary.setDestructionPrice(BigDecimal.ZERO);
inventorySummary.setBrokenNumberPrice(BigDecimal.ZERO);
inventorySummary.setExpireNumberPrice(BigDecimal.ZERO);
inventorySummary.setUseNumber(0);
inventorySummary.setBrokenNumber(0);
inventorySummary.setExpireNumber(0);
inventorySummary.setDestructionNumber(0);
inventorySummary.setFixNumber(0);
inventorySummary.setProperty(ObjectUtil.isNull(inv.getProperty())?0:inv.getProperty());
addSumList.add(inventorySummary); addSumList.add(inventorySummary);
} }
...@@ -671,16 +422,10 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -671,16 +422,10 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
if (CollectionUtil.isNotEmpty(inventorySummaryList)){ if (CollectionUtil.isNotEmpty(inventorySummaryList)){
inventorySummaryService.updateBatchById(inventorySummaryList); inventorySummaryService.updateBatchById(inventorySummaryList);
} }
List<Inventory> list=new ArrayList<>();
for (String key:map.keySet()) { List<Inventory> collect = req.getInventoryList().stream().map(inventory1 -> {
InventoryReq inventoryReq = map.get(key);
if (inventoryReq.getPrice()==req.getPrice()){
Inventory inventory = new Inventory(); Inventory inventory = new Inventory();
BeanPlusUtil.copyProperties(inventoryReq,inventory); BeanPlusUtil.copyProperties(inventory1,inventory);
list.add(inventory);
}
}
List<Inventory> collect = list.stream().map(inventory -> {
inventory.setWarrantyPeriod(req.getWarrantyPeriod()); inventory.setWarrantyPeriod(req.getWarrantyPeriod());
inventory.setMaintenancePeriod(req.getMaintenancePeriod()); inventory.setMaintenancePeriod(req.getMaintenancePeriod());
inventory.setPrice(req.getPrice()); inventory.setPrice(req.getPrice());
...@@ -702,6 +447,36 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory ...@@ -702,6 +447,36 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
} }
} }
private InventorySummary addInvSum(InventoryReq inv,PubOrg pubOrg){
InventorySummary inventorySummary = new InventorySummary();
inventorySummary.setOrgId(inv.getOrgId());
inventorySummary.setTypeId(inv.getTypeId());
inventorySummary.setTypeName(inv.getTypeName());
inventorySummary.setSizeId(inv.getSizeId());
inventorySummary.setSizeName(inv.getSizeName());
inventorySummary.setLocationId(inv.getLocationId());
inventorySummary.setLocationName(inv.getLocationName());
inventorySummary.setValuekey(pubOrg.getOrgCode()+inv.getLocationId()+inv.getTypeId()+inv.getSizeId()+inv.getPrice()+inv.getProperty());
inventorySummary.setOrgName(pubOrg.getOrgName());
inventorySummary.setLocationName(inv.getLocationName());
inventorySummary.setOrgCode(pubOrg.getOrgCode());
inventorySummary.setStockNumber(inv.getStockNum());
inventorySummary.setOutboundNumber(inv.getOutBoundNum());
inventorySummary.setNumber(inv.getStockNum()+inv.getOutBoundNum());
inventorySummary.setLocationType("0");
inventorySummary.setUnitPrice(inv.getPrice());
inventorySummary.setPrice(inv.getPrice().multiply(BigDecimal.valueOf(inventorySummary.getNumber())));
inventorySummary.setDestructionPrice(BigDecimal.ZERO);
inventorySummary.setBrokenNumberPrice(BigDecimal.ZERO);
inventorySummary.setExpireNumberPrice(BigDecimal.ZERO);
inventorySummary.setUseNumber(0);
inventorySummary.setBrokenNumber(0);
inventorySummary.setExpireNumber(0);
inventorySummary.setDestructionNumber(0);
inventorySummary.setFixNumber(0);
inventorySummary.setProperty(ObjectUtil.isNull(inv.getProperty())?0:inv.getProperty());
return inventorySummary;
}
//修改库存信息汇总 //修改库存信息汇总
......
...@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.junmp.jyzb.api.bean.dto.LogSummaryDto; import com.junmp.jyzb.api.bean.dto.LogSummaryDto;
import com.junmp.jyzb.api.bean.dto.NormalInOutDto; import com.junmp.jyzb.api.bean.dto.NormalInOutDto;
import com.junmp.jyzb.api.bean.query.ApplicationReq;
import com.junmp.jyzb.api.bean.query.InAndOutRecordReq.CabinetLogsRecordReq; import com.junmp.jyzb.api.bean.query.InAndOutRecordReq.CabinetLogsRecordReq;
import com.junmp.jyzb.api.bean.query.InAndOutRecordReq.*; import com.junmp.jyzb.api.bean.query.InAndOutRecordReq.*;
import com.junmp.jyzb.api.bean.query.LogDetailReq; import com.junmp.jyzb.api.bean.query.LogDetailReq;
...@@ -104,21 +105,10 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm ...@@ -104,21 +105,10 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm
req.setColumn("create_time"); req.setColumn("create_time");
req.setOrder("desc"); req.setOrder("desc");
} }
LambdaQueryWrapper<LogSummary> eq = createWrapper(req);
LambdaQueryWrapper<LogSummary> eq = new LambdaQueryWrapper<LogSummary>()
.eq(ObjectUtil.isNotNull(req.getOrgId()),LogSummary::getOrgId,req.getOrgId())
.eq(LogSummary::getLocationType,req.getLocationType())
.eq(ObjectUtil.isNotNull(req.getOrderMainId()),LogSummary::getOrderMainId,req.getOrderMainId())
.eq(ObjectUtil.isNotNull(req.getBussinessType()) && !req.getBussinessType().trim().isEmpty(),LogSummary::getBussinessType,req.getBussinessType())
.eq(ObjectUtil.isNotNull(req.getOutInState()) && !req.getOutInState().trim().isEmpty(),LogSummary::getOutInState,req.getOutInState())
.eq(ObjectUtil.isNotNull(req.getLocationId()),LogSummary::getLocationId,req.getLocationId())
.eq(ObjectUtil.isNotNull(req.getUserName()),LogSummary::getUserName,req.getUserName())
.ge(ObjectUtil.isNotNull(req.getStartTime()),LogSummary::getUseTime,req.getStartTime())
.le(ObjectUtil.isNotNull(req.getEndTime()),LogSummary::getUseTime,req.getEndTime())
.like(ObjectUtil.isNotNull(req.getTypeName()),LogSummary::getEquipmentList,req.getTypeName())
.last("order by " + req.getColumn() + " " + req.getOrder());
Page<LogSummary> page = logSummaryService.page(PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize()), eq); Page<LogSummary> page = logSummaryService.page(PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize()), eq);
return PageResultFactory.createPageResult(page); return PageResultFactory.createPageResult(page);
} }
...@@ -136,8 +126,8 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm ...@@ -136,8 +126,8 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm
} }
LogSummary logSummary = logSummaryMapper.ShowInOutRecordsByItemsCount(req); LogSummary logSummary = logSummaryMapper.ShowInOutRecordsByItemsCount(req);
return ObjectUtil.isNull(logSummary)?new LogSummary():logSummary ; return ObjectUtil.isNull(logSummary)?new LogSummary():logSummary ;
} }
//根据条件查询出入库记录(整个单子的汇总记录) //根据条件查询出入库记录(整个单子的汇总记录)
...@@ -151,12 +141,12 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm ...@@ -151,12 +141,12 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm
req.setOrder(req.getOrder().toLowerCase()); req.setOrder(req.getOrder().toLowerCase());
} }
Page<LogSummaryDto> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize()); Page<LogSummaryDto> page = PageFactory.getDefaultPage(req.getPageNo(), req.getPageSize());
Calendar calendarBegin = DateUtil.parseByPatterns(DateUtil.endOfYear(DateTimeUtil.getCurrentDateTime()).toString(), "yyyy-MM-dd hh:mm:ss"); // Calendar calendarBegin = DateUtil.parseByPatterns(DateUtil.endOfYear(DateTimeUtil.getCurrentDateTime()).toString(), "yyyy-MM-dd hh:mm:ss");
Date time = calendarBegin.getTime(); // Date time = calendarBegin.getTime();
Calendar calendarEnd = DateUtil.parseByPatterns(DateUtil.beginOfYear(DateTimeUtil.getCurrentDateTime()).toString(), "yyyy-MM-dd hh:mm:ss"); // Calendar calendarEnd = DateUtil.parseByPatterns(DateUtil.beginOfYear(DateTimeUtil.getCurrentDateTime()).toString(), "yyyy-MM-dd hh:mm:ss");
Date time1 = calendarEnd.getTime(); // Date time1 = calendarEnd.getTime();
req.setStartTime(DateTimeUtil.TimeDateToString(time)); // req.setStartTime(DateTimeUtil.TimeDateToString(time));
req.setEndTime(DateTimeUtil.TimeDateToString(time1)); // req.setEndTime(DateTimeUtil.TimeDateToString(time1));
List<LogSummaryDto> logSummaryList=logSummaryMapper.RecordSumByOrderId(req,(req.getPageNo()-1)*req.getPageSize(), req.getPageSize()); List<LogSummaryDto> logSummaryList=logSummaryMapper.RecordSumByOrderId(req,(req.getPageNo()-1)*req.getPageSize(), req.getPageSize());
LogSummaryDto dto=logSummaryMapper.RecordSumByOrderIdSum(req); LogSummaryDto dto=logSummaryMapper.RecordSumByOrderIdSum(req);
page.setTotal(dto.getCount()); page.setTotal(dto.getCount());
...@@ -173,12 +163,12 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm ...@@ -173,12 +163,12 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm
req.setColumn(req.getColumn().replaceAll("[A-Z]", "_$0").toLowerCase()); req.setColumn(req.getColumn().replaceAll("[A-Z]", "_$0").toLowerCase());
req.setOrder(req.getOrder().toLowerCase()); req.setOrder(req.getOrder().toLowerCase());
} }
Calendar calendarBegin = DateUtil.parseByPatterns(DateUtil.endOfYear(DateTimeUtil.getCurrentDateTime()).toString(), "yyyy-MM-dd hh:mm:ss"); // Calendar calendarBegin = DateUtil.parseByPatterns(DateUtil.endOfYear(DateTimeUtil.getCurrentDateTime()).toString(), "yyyy-MM-dd hh:mm:ss");
Date time = calendarBegin.getTime(); // Date time = calendarBegin.getTime();
Calendar calendarEnd = DateUtil.parseByPatterns(DateUtil.beginOfYear(DateTimeUtil.getCurrentDateTime()).toString(), "yyyy-MM-dd hh:mm:ss"); // Calendar calendarEnd = DateUtil.parseByPatterns(DateUtil.beginOfYear(DateTimeUtil.getCurrentDateTime()).toString(), "yyyy-MM-dd hh:mm:ss");
Date time1 = calendarEnd.getTime(); // Date time1 = calendarEnd.getTime();
req.setStartTime(DateTimeUtil.TimeDateToString(time)); // req.setStartTime(DateTimeUtil.TimeDateToString(time));
req.setEndTime(DateTimeUtil.TimeDateToString(time1)); // req.setEndTime(DateTimeUtil.TimeDateToString(time1));
LogSummaryDto dto=logSummaryMapper.RecordSumByOrderIdSum(req); LogSummaryDto dto=logSummaryMapper.RecordSumByOrderIdSum(req);
return dto; return dto;
} }
...@@ -331,217 +321,6 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm ...@@ -331,217 +321,6 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm
} }
// 对出入库记录进行分类汇总存储()
// public List<NormalInOutDto> saveInOutRecords(OutInLogsReq req) {
//
// //返回结果,用于日常出入库时计算更新库存汇总表
// List<SummaryLogReq> logSummaryList = req.getLogList();
//
// //遍历logSummaryList查询出没有单据的作为日常出入库,并再次存放到list中,后面用于进行修改库存汇总
// //返回returnList结果,用于日常出入库时计算更新库存汇总表
// List<NormalInOutDto> returnList=new ArrayList<>();
// //存一个list用于修改库存inventory表的数据(采购时那么这个inventoryList就为空)
// List<Inventory> inventoryList=new ArrayList<>();
// //存一个list用于修改库存warehosuseInventory表的数据(采购时那么这个wInventoryList就为空)
// List<WarehouseInventory> wInbentoryList=new ArrayList<>();
// List<OrderLog> orderLogList=new ArrayList<>();
// String orderMainId="";
//
// List<LogSummary> sumList=new ArrayList<>();
// OrderMain ordermain=null;
// for (SummaryLogReq logreq:logSummaryList) {
// if (ObjectUtil.isNotNull(logreq.getPicture())){
// byte[] imageBytes = Base64.getDecoder().decode(logreq.getPicture());
// MultipartFile picture = new MockMultipartFile("sample", imageBytes);
// // 图片文件保存路径和文件名
// SysFileInfoReq sysFileInfoReq = new SysFileInfoReq();
// sysFileInfoReq.setFileBucket("jyzb");
// sysFileInfoReq.setFileLocation(3);
// sysFileInfoReq.setFileObjectName("OutInPrice/"+logreq.getOrgId()+"/");
// SysFileInfoResp sysFileInfoResp = sysFileInfoService.uploadFile(picture, sysFileInfoReq);
// logreq.setPicture(sysFileInfoResp.getAccessUrl());
// }
//
// if (ObjectUtil.isNotNull(logreq.getOrderMainId())){
// orderMainId=logreq.getOrderMainId();
// }
//
// if (ObjectUtil.isNotEmpty(orderMainId)){
// ordermain = orderMainService.getById(orderMainId);
// }
// //如果类型为normal,那么则表示作为日常出入库的记录,否则则作为单据的出入库记录
// List<DetailLogReq> logList = logreq.getLogDetailList();
//
// //出入库list
// List<LogDetail> collect = new ArrayList<>();
// LogSummary logSummary = saveLogSummary(logreq,logreq.getLocationId(),logreq.getLocationName(),logreq.getOutInState());
//
// String string="";
// String stringQuick="";
// if (logSummary.getOutInState().equals("in")){
// string=string+logSummary.getLocationName()+":入库【"+logSummary.getEquipmentList()+"】,数量:"+logSummary.getNumber()+"\n";
// }else {
// string=string+logSummary.getLocationName()+":出库【"+logSummary.getEquipmentList()+"】,数量:"+logSummary.getNumber()+"\n";
// }
// LogSummary logSummaryQuick=new LogSummary();
// if (logreq.getBussinessType().equals("quick")){//如果是快速出库的同时需要创建快速入库
// logSummaryQuick= saveLogSummary(logreq,ordermain.getLocationId(),ordermain.getLocationName(),"in");
// sumList.add(logSummaryQuick);
// stringQuick=stringQuick+logSummaryQuick.getLocationName()+":入库【"+logSummaryQuick.getEquipmentList()+"】,数量:"+logSummary.getNumber()+"\n";
// }
// sumList.add(logSummary);
// logSummaryService.saveBatch(sumList);
// sumList.clear();
// Map<String, String> map = setState(logreq.getOutInState(), logreq.getBussinessType());
//
//
// for (DetailLogReq detailLogReq : logList) {
// //将所有装备信息进行存放(为后面计算汇总信息)
// if (logreq.getBussinessType().equals("normal")) {
// NormalInOutDto normalInOutDto = new NormalInOutDto();
// BeanPlusUtil.copyProperties(detailLogReq, normalInOutDto);
// normalInOutDto.setLocationId(logSummary.getLocationId());
// normalInOutDto.setLocationName(logSummary.getLocationName());
// normalInOutDto.setOrgId(logSummary.getOrgId());
// normalInOutDto.setOrgName(logSummary.getOrgName());
// normalInOutDto.setNumber(1);
// normalInOutDto.setOutInState(logSummary.getOutInState());
// returnList.add(normalInOutDto);
// }
// //判断logSummary是否为采购,快速移库,和领用出库
// //如果是采购则不处理,因为采购的inventory是跟着单子来处理的,其他的单子直接根据出入库记录来处理
// if (!logreq.getBussinessType().equals("purchase") && !logreq.getBussinessType().equals("quick") ){
//// if (logreq.getOutInState().equals("in")){
// Inventory inventory = saveInventory(logreq.getOrgId(),logreq.getLocationId(),logreq,detailLogReq, map, logSummary.getOutInState());
// inventoryList.add(inventory);
//
// }
//// //如果是快速移库,那么直接将物资的locationId进行修改
// if(logreq.getBussinessType().equals("quick")){
// Inventory inventory = saveInventory(logreq.getOrgId(),ordermain.getLocationId(),logreq,detailLogReq, map, "in");
// inventoryList.add(inventory);
// }
// //存放logdetail信息
// LogDetail logDetail = new LogDetail();
// LogDetail logDetailQuick=new LogDetail();
// BeanPlusUtil.copyProperties(detailLogReq, logDetail);
// logDetail.setSummaryId(logSummary.getId());
// logDetail.setOrgId(logSummary.getOrgId());
// logDetail.setCreateTime(DateTimeUtil.getCurrentDateTime());
// logDetail.setBussinessType(logreq.getBussinessType());
// logDetail.setOutInState(logreq.getOutInState());
// if (logreq.getBussinessType().equals("quick")){
// BeanPlusUtil.copyProperties(logDetail,logDetailQuick);
// logDetailQuick.setSummaryId(logSummaryQuick.getId());
// logDetailQuick.setOutInState("in");
// collect.add(logDetailQuick);
// }
// collect.add(logDetail);
//
// }
//
// boolean b = logDetailService.saveBatch(collect);
// //创建出入库日志
// if (ObjectUtil.isNotNull(logSummary.getOrderMainId())){
// OrderLog orderLog = addLog(logSummary,string);
// OrderLog qucik = new OrderLog();
// if (logreq.getBussinessType().equals("quick")){
// qucik=addLog(logSummaryQuick,stringQuick);
// orderLogList.add(qucik);
// }
// orderLogList.add(orderLog);
// }
// }
// //判断是否有orderId的单子出入库,如果有则直接添加
// if (orderLogList.size()>0){
// boolean b = orderLogService.saveBatch(orderLogList);
// }
//
// //修改inventory表中的数据(如果不为空则表示不是采购单或者已经将采购单的信息过滤掉)
//
// if (inventoryList.size()>0){
//
// LambdaUpdateWrapper<Inventory> updateStateWrapper1 = Wrappers.lambdaUpdate();
// LambdaUpdateWrapper<Inventory> allocateInWrapper1 = Wrappers.lambdaUpdate();
// LambdaUpdateWrapper<WarehouseInventory> updateStateWrapper2 = Wrappers.lambdaUpdate();
// LambdaUpdateWrapper<WarehouseInventory> allocateInWrapper2 = Wrappers.lambdaUpdate();
// LambdaQueryWrapper<WarehouseInventory> destroyOutWrapper =Wrappers.lambdaQuery();
// for (Inventory inventory:inventoryList) {
// if (inventory.getBussinessType().equals("allocate") && inventory.getLocationState().equals("in") && !ObjectUtil.isNull(ordermain)){
// //调拨入库
// allocateInWrapper1.or().eq(Inventory::getEpc,inventory.getEpc())
// .set(Inventory::getOrgId,inventory.getOrgId())
// .set(Inventory::getLocationId,inventory.getLocationId())
// .set(Inventory::getLocationState,"in");
// allocateInWrapper2.or().eq(WarehouseInventory::getEpc,inventory.getEpc())
// .set(WarehouseInventory::getOrgId,inventory.getOrgId())
// .set(WarehouseInventory::getLocationId,inventory.getLocationId())
// .set(WarehouseInventory::getLocationState,"in");
//
// } else if (inventory.getBussinessType().equals("allocate") && inventory.getLocationState().equals("out") && !ObjectUtil.isNull(ordermain)){
// //调拨出库,不操作
// allocateInWrapper1.or().eq(Inventory::getEpc,inventory.getEpc())
// .set(Inventory::getOrgId,null)
// .set(Inventory::getLocationId,null)
// .set(Inventory::getLocationState,"out");
// allocateInWrapper2.or().eq(WarehouseInventory::getEpc,inventory.getEpc())
// .set(WarehouseInventory::getOrgId,null)
// .set(WarehouseInventory::getLocationId,null)
// .set(WarehouseInventory::getLocationState,"out");
// }else if (inventory.getBussinessType().equals("destruction")){
// updateStateWrapper1.or().eq(Inventory::getEpc,inventory.getEpc())
// .set(Inventory::getLocationState,"out")
// .set(Inventory::getBussinessState,"destruction")
// .set(Inventory::getLocationId,inventory.getLocationId())
// .set(Inventory::getState,"destory");
// destroyOutWrapper.or().eq(WarehouseInventory::getEpc,inventory.getEpc());
// }else{
// //其他情况
// if (inventory.getBussinessType().equals("quick")){
// updateStateWrapper1.or().eq(Inventory::getEpc,inventory.getEpc())
// .set(Inventory::getLocationState,"in")
// .set(Inventory::getBussinessState,"normal")
// .set(Inventory::getLocationId,inventory.getLocationId())
// .set(Inventory::getState,"normal");
//
// updateStateWrapper2.or().eq(WarehouseInventory::getEpc,inventory.getEpc())
// .set(WarehouseInventory::getLocationId,inventory.getLocationId())
// .set(WarehouseInventory::getLocationState,"in");
// }else {
// updateStateWrapper1.or().eq(Inventory::getEpc,inventory.getEpc())
// .set(Inventory::getLocationState,inventory.getLocationState())
// .set(Inventory::getBussinessState,inventory.getBussinessState())
// .set(Inventory::getState,inventory.getState());
//
// updateStateWrapper2.or().eq(WarehouseInventory::getEpc,inventory.getEpc())
// .set(WarehouseInventory::getLocationState,inventory.getLocationState());
//
// }
//
//
// }
//
// }
//
// if (!updateStateWrapper1.isEmptyOfWhere()){
//
// inventoryService.update(updateStateWrapper1);
//
// warehouseInventoryService.update(updateStateWrapper2);
// }
//
// if (!allocateInWrapper1.isEmptyOfWhere()){
//
// inventoryService.update(allocateInWrapper1);
// warehouseInventoryService.update(allocateInWrapper2);
// }
//
// }
//
// return returnList;
// }
private OrderLog addLog(LogSummary logSummary,String string){ private OrderLog addLog(LogSummary logSummary,String string){
OrderLog orderLog = new OrderLog(); OrderLog orderLog = new OrderLog();
orderLog.setId(UUID.randomUUID().toString()); orderLog.setId(UUID.randomUUID().toString());
...@@ -974,7 +753,23 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm ...@@ -974,7 +753,23 @@ public class LogSummaryServiceImpl extends ServiceImpl<LogSummaryMapper, LogSumm
return true; return true;
} }
} private LambdaQueryWrapper<LogSummary> createWrapper(LogSummaryReq req) {
LambdaQueryWrapper<LogSummary> eq = new LambdaQueryWrapper<LogSummary>()
.eq(ObjectUtil.isNotNull(req.getOrgId()),LogSummary::getOrgId,req.getOrgId())
.eq(LogSummary::getLocationType,req.getLocationType())
.eq(ObjectUtil.isNotNull(req.getOrderMainId()),LogSummary::getOrderMainId,req.getOrderMainId())
.eq(ObjectUtil.isNotNull(req.getBussinessType()) && !req.getBussinessType().trim().isEmpty(),LogSummary::getBussinessType,req.getBussinessType())
.eq(ObjectUtil.isNotNull(req.getOutInState()) && !req.getOutInState().trim().isEmpty(),LogSummary::getOutInState,req.getOutInState())
.eq(ObjectUtil.isNotNull(req.getLocationId()),LogSummary::getLocationId,req.getLocationId())
.like(ObjectUtil.isNotNull(req.getUserName()),LogSummary::getUserName,req.getUserName())
.ge(ObjectUtil.isNotNull(req.getStartTime()),LogSummary::getUseTime,req.getStartTime())
.le(ObjectUtil.isNotNull(req.getEndTime()),LogSummary::getUseTime,req.getEndTime())
.like(ObjectUtil.isNotNull(req.getTypeName()),LogSummary::getEquipmentList,req.getTypeName())
.last("order by " + req.getColumn() + " " + req.getOrder());
return eq;
}
}
......
...@@ -902,10 +902,9 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -902,10 +902,9 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
} }
//前端传递的子单数据 //前端传递的子单数据
List<UpdateOrderDetailReq> reqList = req.getDetailList(); List<UpdateOrderDetailReq> reqList = req.getDetailList();
//将记账数量进行相加 //将记账数量进行相加
Integer updateQuantity=0; Integer updateQuantity=0;
//将价格进行添加修改
BigDecimal priceTotal=new BigDecimal(0);
//获取子单据 //获取子单据
List<OrderDetail> list = orderDetailService.list(new LambdaQueryWrapper<OrderDetail>() List<OrderDetail> list = orderDetailService.list(new LambdaQueryWrapper<OrderDetail>()
.eq(OrderDetail::getOrderId,req.getId())); .eq(OrderDetail::getOrderId,req.getId()));
...@@ -929,12 +928,33 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -929,12 +928,33 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
List<WarehouseInventory> addWareInvList=new ArrayList<>(); List<WarehouseInventory> addWareInvList=new ArrayList<>();
//编辑装备(出库) //编辑装备(出库)
List<Inventory> updateInvList=new ArrayList<>(); List<Inventory> updateInvList=new ArrayList<>();
//用于判断是否是空账
boolean flag=false;
//遍历子单 //遍历子单
for (UpdateOrderDetailReq uploadDetailReq : reqList) { for (UpdateOrderDetailReq uploadDetailReq : reqList) {
OrderDetail orderDetail = new OrderDetail(); OrderDetail orderDetail = new OrderDetail();
BeanPlusUtil.copyProperties(uploadDetailReq,orderDetail); BeanPlusUtil.copyProperties(uploadDetailReq,orderDetail);
//记空账(识别0,记账0)
if (uploadDetailReq.getActualNum()==0 && uploadDetailReq.getModifyQuantity()==0){
//添加出入库日志记录
if (orderMain.getOrderType().equals("in")){
s = s+uploadDetailReq.getTypeName()+"【"+
uploadDetailReq.getSizeName()+"】,单价:"+uploadDetailReq.getPrice()
+",数量实入:0,记账:0"+"\n";
}else {
s = s+uploadDetailReq.getTypeName()+"【"+
uploadDetailReq.getSizeName()+"】,单价:"+uploadDetailReq.getPrice()
+",数量实出:0,记账:0"+"\n";
}
orderDetail.setModifyQuantity(uploadDetailReq.getModifyQuantity());
orderDetail.setUpdateTime(DateTimeUtil.getCurrentDateTime());
orderDetailList.add(orderDetail);
updateQuantity+=orderDetail.getModifyQuantity();
continue;
}
flag=true;
List<DetailJsonReq> JsonList = uploadDetailReq.getChildJson(); List<DetailJsonReq> JsonList = uploadDetailReq.getChildJson();
String jsonString = JSONObject.toJSONString(JsonList); String jsonString = JSONObject.toJSONString(JsonList);
orderDetail.setDetailJson(jsonString); orderDetail.setDetailJson(jsonString);
...@@ -945,7 +965,6 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -945,7 +965,6 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
if (ObjectUtil.isNull(uploadDetailReq.getModifyQuantity())){ if (ObjectUtil.isNull(uploadDetailReq.getModifyQuantity())){
throw new ServiceException(OrderExceptionEnum.ORDER_NUM_IS_NULL); throw new ServiceException(OrderExceptionEnum.ORDER_NUM_IS_NULL);
} }
if (uploadDetailReq.getModifyQuantity() >= 0 ){ if (uploadDetailReq.getModifyQuantity() >= 0 ){
//遍历子单据下面的详细记账信息 //遍历子单据下面的详细记账信息
...@@ -1089,6 +1108,18 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -1089,6 +1108,18 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
throw new ServiceException(OrderExceptionEnum.ORDERDETAIL_ERROR); throw new ServiceException(OrderExceptionEnum.ORDERDETAIL_ERROR);
} }
} }
//记账0
if (!flag){
orderMain.setActualQuantity(updateQuantity);
orderMain.setOrderState("finished");
//修改记账状态,0未记账,1已记账
orderMain.setManualState(1);
orderMain.setUpdateTime(DateTimeUtil.getCurrentDateTime());
boolean a = orderDetailService.updateBatchById(orderDetailList);
boolean b = updateById(orderMain);
boolean c = saveAccountingLog(req, s, updateQuantity);
return a && b && c;
}
//入库添加虚拟装备 //入库添加虚拟装备
if (CollectionUtil.isNotEmpty(addInvList)){ if (CollectionUtil.isNotEmpty(addInvList)){
...@@ -1108,14 +1139,15 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -1108,14 +1139,15 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
LogDetailReq logDetailReq = new LogDetailReq(); LogDetailReq logDetailReq = new LogDetailReq();
BeanPlusUtil.copyProperties(inv,logDetailReq); BeanPlusUtil.copyProperties(inv,logDetailReq);
logDetailReq.setOutInState(req.getOrderType()); logDetailReq.setOutInState(req.getOrderType());
logDetailReq.setBussinessType(orderMain.getBussinessType());
logDetailReq.setCreateTime(DateTimeUtil.getCurrentDateTime());
if (CollectionUtil.isEmpty(logDetailList)) { if (CollectionUtil.isEmpty(logDetailList)) {
lsReq.setLogList(new ArrayList<>()); lsReq.setLogList(new ArrayList<>());
logDetailList = lsReq.getLogList(); logDetailList = lsReq.getLogList();
} }
logDetailList.add(logDetailReq); logDetailList.add(logDetailReq);
LogSummaryReq logSummaryReq = logMap.get(inv.getLocationId()); lsReq.setLogList(logDetailList);
logSummaryReq.setLogList(logDetailList); logMap.put(inv.getLocationId(),lsReq);
logMap.put(inv.getLocationId(),logSummaryReq);
} }
} }
//出库记账logDetail //出库记账logDetail
...@@ -1127,15 +1159,15 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain ...@@ -1127,15 +1159,15 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
LogDetailReq logDetailReq = new LogDetailReq(); LogDetailReq logDetailReq = new LogDetailReq();
BeanPlusUtil.copyProperties(inv,logDetailReq); BeanPlusUtil.copyProperties(inv,logDetailReq);
logDetailReq.setOutInState(req.getOrderType()); logDetailReq.setOutInState(req.getOrderType());
logDetailReq.setBussinessType(orderMain.getBussinessType());
logDetailReq.setCreateTime(DateTimeUtil.getCurrentDateTime()); logDetailReq.setCreateTime(DateTimeUtil.getCurrentDateTime());
if (CollectionUtil.isEmpty(logDetailList)) { if (CollectionUtil.isEmpty(logDetailList)) {
lsReq.setLogList(new ArrayList<>()); lsReq.setLogList(new ArrayList<>());
logDetailList = lsReq.getLogList(); logDetailList = lsReq.getLogList();
} }
logDetailList.add(logDetailReq); logDetailList.add(logDetailReq);
LogSummaryReq logSummaryReq = logMap.get(inv.getLocationId()); lsReq.setLogList(logDetailList);
logSummaryReq.setLogList(logDetailList); logMap.put(inv.getLocationId(),lsReq);
logMap.put(inv.getLocationId(),logSummaryReq);
} }
} }
//出库更新装备状态和出库状态 //出库更新装备状态和出库状态
......
...@@ -203,7 +203,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -203,7 +203,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
} }
//判断警员编号是否已经存在 //判断警员编号是否已经存在
List<Policeman> list = list(new LambdaQueryWrapper<Policeman>().eq(Policeman::getPoliceCode, req.getPoliceCode()) List<Policeman> list = list(new LambdaQueryWrapper<Policeman>().eq(Policeman::getPoliceCode, req.getPoliceCode())
.eq(Policeman::getIdentity, req.getIdentity())); .eq(Policeman::getIdentity, req.getIdentity()).or().eq(Policeman::getName, req.getName()));
if (CollectionUtil.isNotEmpty(list)){ if (CollectionUtil.isNotEmpty(list)){
throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS); throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS);
} }
...@@ -230,7 +230,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -230,7 +230,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
policeman.setState(1); policeman.setState(1);
policeman.setUserId(sysUser.getUserId()); policeman.setUserId(sysUser.getUserId());
//如果有照片,将警员照片直接复制一下以防万一 //如果有照片,将警员照片直接复制一下以防万一
policeman.setPhoto(req.getFaceInfo()); policeman.setPhoto(req.getPhoto());
policeman.setCreateTime(DateTimeUtil.getCurrentDateTime()); policeman.setCreateTime(DateTimeUtil.getCurrentDateTime());
policeman.setUpdateTime(DateTimeUtil.getCurrentDateTime()); policeman.setUpdateTime(DateTimeUtil.getCurrentDateTime());
save(policeman); save(policeman);
...@@ -605,7 +605,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -605,7 +605,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS); throw new ServiceException(PolicemanExceptionEnum.POLICECODE_IS_EXISTS);
} }
} }
one.setPhoto(req.getFaceInfo()); one.setPhoto(req.getPhoto());
one.setUpdateTime(DateTimeUtil.getCurrentDateTime()); one.setUpdateTime(DateTimeUtil.getCurrentDateTime());
SysUser user= sysUserService.getById(req.getUserId()); SysUser user= sysUserService.getById(req.getUserId());
user.setPassword(req.getPassword()); user.setPassword(req.getPassword());
...@@ -1545,13 +1545,9 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -1545,13 +1545,9 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
.eq(CabinetBoxPolice::getPoliceId,policeman.getId())); .eq(CabinetBoxPolice::getPoliceId,policeman.getId()));
//判断前端传递的装备列表字段是否为空,如果为空则表示该警员不拿走任何装备信息(不做任何操作) //判断前端传递的装备列表字段是否为空,如果为空则表示该警员不拿走任何装备信息(不做任何操作)
if (ObjectUtil.isNull(req.getDetailList()) || req.getDetailList().trim().isEmpty()){ if (ObjectUtil.isNotNull(req.getDetailList()) || !req.getDetailList().trim().isEmpty()){
// if (list1.size()>0){
//// policeEquipmentService.remove(eq);
// policeEquipmentService.removeBatchByIds(list1);
// }
} else {//将该警员拿走的装备的组织机构设置为空,并且其他装备进行跟警员进行解绑删除 //将该警员拿走的装备的组织机构设置为空,并且其他装备进行跟警员进行解绑删除
List<PoliceEquipment> removeList=new ArrayList<>(); List<PoliceEquipment> removeList=new ArrayList<>();
//更新装备(将装备信息进行删除) //更新装备(将装备信息进行删除)
List<PoliceEquipment> updateList=new ArrayList<>(); List<PoliceEquipment> updateList=new ArrayList<>();
...@@ -1584,26 +1580,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman ...@@ -1584,26 +1580,7 @@ public class PolicemanServiceImpl extends ServiceImpl<PolicemanMapper, Policeman
policeEquipmentService.updateBatchById(updateList); policeEquipmentService.updateBatchById(updateList);
policeEquipmentService.removeBatchByIds(removeList); policeEquipmentService.removeBatchByIds(removeList);
// if (searchItem.size()>0)
// {
// //修改库存数量
// List<InventorySummary> inventorySummaryList = inventorySummaryMapper.selectSumByItems(searchItem);
// List<InventorySummary> updateSummaryList=new ArrayList<>();
// for (InventorySummary is:inventorySummaryList) {
// for ( Object[] one: searchItem) {
// if (is.getLocationId().equals(one[1]) && is.getTypeId().equals(one[2])
// && is.getSizeId().equals(one[3]) && is.getUnitPrice().compareTo(new BigDecimal(one[4].toString()))==0){
// is.setOutboundNumber(is.getOutboundNumber()-Integer.parseInt(one[5].toString()));
// is.setNumber(is.getNumber()-Integer.parseInt(one[5].toString()));
// updateSummaryList.add(is);
// break;
// }
// }
// }
// if (updateSummaryList.size()>0){
// inventorySummaryService.updateBatchById(updateSummaryList);
// }
// }
} }
//记录日志(如果警员携带装备,则进行记录 ) //记录日志(如果警员携带装备,则进行记录 )
if (ObjectUtil.isNotNull(reqEquipments)){ if (ObjectUtil.isNotNull(reqEquipments)){
......
...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateTime; ...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.junmp.junmpProcess.dto.json.UserInfo; import com.junmp.junmpProcess.dto.json.UserInfo;
import com.junmp.jyzb.service.PublicService; import com.junmp.jyzb.service.PublicService;
...@@ -119,4 +120,16 @@ public class PublicServiceImpl implements PublicService { ...@@ -119,4 +120,16 @@ public class PublicServiceImpl implements PublicService {
return true; return true;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public boolean setReadMessage(MessageReq req) {
List<Long> msgIdList = req.getMsgIdList();
List<SysMessage> list = sysMessageService.list(new LambdaQueryWrapper<SysMessage>().in(SysMessage::getMsgId, msgIdList));
List<Long> collect = list.stream().map(SysMessage::getBizId).collect(Collectors.toList());
List<SysMessage> list1 = sysMessageService.list(new LambdaQueryWrapper<SysMessage>().in(SysMessage::getBizId, collect));
return sysMessageService.update(new LambdaUpdateWrapper<SysMessage>()
.set(SysMessage::getReadFlag, 1)
.in(SysMessage::getBizId, list1));
}
} }
...@@ -570,7 +570,8 @@ ...@@ -570,7 +570,8 @@
( (
sum( CASE WHEN `base_inventory_summary`.`location_type` = 0 THEN `base_inventory_summary`.`stock_number` ELSE 0 END ) + sum( CASE WHEN `base_inventory_summary`.`location_type` = 0 THEN `base_inventory_summary`.`stock_number` ELSE 0 END ) +
sum( CASE WHEN `base_inventory_summary`.`location_type` = 0 THEN `base_inventory_summary`.`outbound_number` ELSE 0 END ) + sum( CASE WHEN `base_inventory_summary`.`location_type` = 0 THEN `base_inventory_summary`.`outbound_number` ELSE 0 END ) +
sum( CASE WHEN `base_inventory_summary`.`location_type` = 0 THEN `base_inventory_summary`.`destruction_number` ELSE 0 END ) sum( CASE WHEN `base_inventory_summary`.`location_type` = 1 THEN `base_inventory_summary`.`stock_number` ELSE 0 END )+
sum( CASE WHEN `base_inventory_summary`.`location_type` = 1 THEN `base_inventory_summary`.`stock_number` ELSE 0 END )
) AS total_number, ) AS total_number,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 0 ) THEN `base_inventory_summary`.`stock_number` ELSE 0 END ) AS `ck_stock_number`, sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 0 ) THEN `base_inventory_summary`.`stock_number` ELSE 0 END ) AS `ck_stock_number`,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 0 ) THEN `base_inventory_summary`.`outbound_number` ELSE 0 END ) AS `ck_outbound_number`, sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 0 ) THEN `base_inventory_summary`.`outbound_number` ELSE 0 END ) AS `ck_outbound_number`,
...@@ -759,27 +760,24 @@ ...@@ -759,27 +760,24 @@
<select id="selectSumByItemsCount" resultType="java.lang.Integer" <select id="selectSumByItemsCount" resultType="java.lang.Integer"
parameterType="com.junmp.jyzb.api.bean.query.InventoryReq"> parameterType="com.junmp.jyzb.api.bean.query.InventoryReq">
select count(*) from ( select count(*) from (
SELECT wi.type_id,wi.size_id,wi.shelf_id,wi.shelf_location, wi.epc,wi.org_id,wi.location_state, SELECT wi.type_id,wi.size_id,wi.shelf_id,wi.shelf_location, wi.epc,wi.org_id,wi.location_state,wi.location_name,wi.type_name,wi.size_name,wi.org_name,
wi.location_type,wi.location_id,i.id,i.supplier_id,i.price,i.state,i.bussiness_state, wi.location_type,wi.location_id,i.id,i.supplier_id,i.price,i.state,i.bussiness_state,
i.production_date,i.warranty_period,i.maintenance_period, i.term_state, i.production_date,i.warranty_period,i.maintenance_period, i.term_state,i.property,
i.area_id,et.name as type_name,es.name as size_name,po.org_name as org_name, i.area_id,
bs.name as supplier_name,COALESCE(bc.name, bw.name) as location_name, bs.name as supplier_name,
es.photo as photo,es.instructions as instructions (select instructions FROM base_equipment_type where id=#{req.typeId}) as instructions,
(select photo FROM base_equipment_type where id=#{req.typeId}) as type_photo,
es.photo as size_photo
FROM base_warehouse_inventory wi FROM base_warehouse_inventory wi
LEFT JOIN base_inventory i ON i.epc = wi.epc LEFT JOIN base_inventory i ON i.epc = wi.epc
LEFT JOIN base_equipment_type et ON et.id = i.type_id LEFT JOIN base_equipment_size es ON wi.size_id = es.id
LEFT JOIN base_equipment_size es ON es.id = i.size_id
LEFT JOIN pub_org po ON i.org_id_int = po.org_id
LEFT JOIN base_supplier bs ON bs.id = i.supplier_id LEFT JOIN base_supplier bs ON bs.id = i.supplier_id
LEFT JOIN base_cabinet_box bcb ON i.location_id = bcb.id AND i.location_type = 1 WHERE wi.org_id=#{req.orgId} and wi.type_id=#{req.typeId} and i.state !="destory"
LEFT JOIN base_cabinet bc ON bcb.cabinet_id = bc.id
LEFT JOIN base_warehouse bw ON i.location_id = bw.id AND i.location_type = 0
WHERE wi.org_id=#{req.orgId} and wi.type_id=#{req.typeId}
<if test="req.locationType !='all' and req.locationType != null"> <if test="req.locationType !='all' and req.locationType != null">
and wi.location_type=#{req.locationType} and wi.location_type=#{req.locationType}
</if> </if>
<if test="req.warehouseId != null and req.warehouseId != ''"> <if test="req.locationId != null and req.locationId != ''">
and wi.location_id =#{req.warehouseId} and wi.location_id =#{req.locationId}
</if> </if>
<if test="req.termState!= -1"> <if test="req.termState!= -1">
and i.term_state=#{req.termState} and i.term_state=#{req.termState}
...@@ -799,28 +797,24 @@ ...@@ -799,28 +797,24 @@
<if test="req.maintenancePeriod != null and req.maintenancePeriod != ''"> <if test="req.maintenancePeriod != null and req.maintenancePeriod != ''">
and i.maintenance_period=#{req.maintenancePeriod} and i.maintenance_period=#{req.maintenancePeriod}
</if> </if>
ORDER BY wi.type_id,i.size_id ORDER BY wi.type_id,i.size_id
) as a ) as a
</select> </select>
<select id="GetDetailByTerms" resultType="com.junmp.jyzb.api.bean.dto.InventoryDto"> <select id="GetDetailByTerms" resultType="com.junmp.jyzb.api.bean.dto.InventoryDto">
SELECT wi.type_id,wi.size_id,wi.shelf_id,wi.shelf_location, wi.epc,wi.org_id,wi.location_state, SELECT wi.type_id,wi.size_id,wi.shelf_id,wi.shelf_location, wi.epc,wi.org_id,wi.location_state,wi.location_name,wi.type_name,wi.size_name,wi.org_name,
wi.location_type,wi.location_id,i.id,i.supplier_id,i.price,i.state,i.bussiness_state, wi.location_type,wi.location_id,i.id,i.supplier_id,i.price,i.state,i.bussiness_state,
i.production_date,i.warranty_period,i.maintenance_period, i.term_state,i.property, i.production_date,i.warranty_period,i.maintenance_period, i.term_state,i.property,
i.area_id,et.name as type_name,es.name as size_name,po.org_name as org_name, i.area_id,
bs.name as supplier_name,COALESCE(bc.name, bw.name) as location_name, bs.name as supplier_name,
es.photo as photo,es.instructions as instructions,et.photo as type_photo,es.photo as size_photo (select instructions FROM base_equipment_type where id=#{req.typeId}) as instructions,
(select photo FROM base_equipment_type where id=#{req.typeId}) as type_photo,
es.photo as size_photo
FROM base_warehouse_inventory wi FROM base_warehouse_inventory wi
LEFT JOIN base_inventory i ON i.epc = wi.epc LEFT JOIN base_inventory i ON i.epc = wi.epc
LEFT JOIN base_equipment_type et ON et.id = i.type_id LEFT JOIN base_equipment_size es ON wi.size_id = es.id
LEFT JOIN base_equipment_size es ON es.id = i.size_id
LEFT JOIN pub_org po ON i.org_id_int = po.org_id
LEFT JOIN base_supplier bs ON bs.id = i.supplier_id LEFT JOIN base_supplier bs ON bs.id = i.supplier_id
LEFT JOIN base_cabinet_box bcb ON i.location_id = bcb.id AND i.location_type = 1 WHERE wi.org_id=#{req.orgId} and wi.type_id=#{req.typeId} and i.state !="destory"
LEFT JOIN base_cabinet bc ON bcb.cabinet_id = bc.id
LEFT JOIN base_warehouse bw ON i.location_id = bw.id AND i.location_type = 0
WHERE wi.org_id=#{req.orgId} and wi.type_id=#{req.typeId}
...@@ -858,8 +852,8 @@ ...@@ -858,8 +852,8 @@
<if test="req.locationType !='all' and req.locationType != null"> <if test="req.locationType !='all' and req.locationType != null">
and wi.location_type=#{req.locationType} and wi.location_type=#{req.locationType}
</if> </if>
<if test="req.warehouseId != null and req.warehouseId != ''"> <if test="req.locationId != null and req.locationId != ''">
and wi.location_id =#{req.warehouseId} and wi.location_id =#{req.locationId}
</if> </if>
<if test="req.termState!= -1"> <if test="req.termState!= -1">
and i.term_state=#{req.termState} and i.term_state=#{req.termState}
...@@ -879,7 +873,6 @@ ...@@ -879,7 +873,6 @@
<if test="req.maintenancePeriod != null and req.maintenancePeriod != ''"> <if test="req.maintenancePeriod != null and req.maintenancePeriod != ''">
and i.maintenance_period=#{req.maintenancePeriod} and i.maintenance_period=#{req.maintenancePeriod}
</if> </if>
ORDER BY wi.type_id,i.size_id ORDER BY wi.type_id,i.size_id
<if test="pageNo != null and pageNo != '' and pageSize != null and pageSize != '' "> <if test="pageNo != null and pageNo != '' and pageSize != null and pageSize != '' ">
limit #{pageNo},#{pageSize} limit #{pageNo},#{pageSize}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.junmp.jyzb.mapper.InventorySummaryMapper">
<resultMap id="BaseResultMap" type="com.junmp.jyzb.entity.InventorySummary">
<!--@mbg.generated-->
<!--@Table base_inventory_summary-->
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="org_id" jdbcType="VARCHAR" property="orgId" />
<result column="org_name" jdbcType="VARCHAR" property="orgName" />
<result column="type_id" jdbcType="VARCHAR" property="typeId" />
<result column="type_name" jdbcType="VARCHAR" property="typeName" />
<result column="size_id" jdbcType="VARCHAR" property="sizeId" />
<result column="size_name" jdbcType="VARCHAR" property="sizeName" />
<result column="location_type" jdbcType="VARCHAR" property="locationType" />
<result column="location_id" jdbcType="VARCHAR" property="locationId" />
<result column="location_name" jdbcType="VARCHAR" property="locationName" />
<result column="number" jdbcType="INTEGER" property="number" />
<result column="price" jdbcType="DECIMAL" property="price" />
<result column="stock_number" jdbcType="INTEGER" property="stockNumber" />
<result column="outbound_number" jdbcType="INTEGER" property="outboundNumber" />
<result column="destruction_number" jdbcType="INTEGER" property="destructionNumber" />
<result column="expire_number" jdbcType="INTEGER" property="expireNumber" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="threshold" jdbcType="INTEGER" property="threshold" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, org_id, org_name, type_id, type_name, size_id, size_name, location_type, location_id,
location_name, `number`, price, stock_number, outbound_number,
destruction_number, expire_number, create_time, update_time,threshold
</sql>
<select id="GetInventorySumInfo" resultType="com.junmp.jyzb.api.bean.dto.InventorySumDto"
parameterType="com.junmp.jyzb.api.bean.query.InventorySumReq">
select max(bis.org_id_int) as orgId,max(bis.org_name) as orgName,bis.location_id,max(bis.location_name) as location_name
<if test="req.locationId !=null and req.locationId != ''">
,bis.type_id,max(bis.type_name) as type_name,bet.unit,bet.unit_type
</if>
<if test="req.typeId != null and req.typeId != ''">
,bis.size_id,max(bis.size_name) as size_name
</if>
<if test="req.sizeId !=null and req.sizeId != ''">
,bis.unit_price,max(bis.stock_number) as stock_number
</if>
FROM base_inventory_summary bis
join base_equipment_type bet on bet.id = bis.type_id
where org_id_int =#{req.orgId}
<if test="req.locationId !=null and req.locationId != ''">
and location_id=#{req.locationId}
</if>
<if test="req.typeId != null and req.typeId != ''">
and type_id=#{req.typeId}
</if>
<if test="req.sizeId !=null and req.sizeId != ''">
and size_id=#{req.sizeId}
</if>
GROUP BY bis.location_id
<if test="req.locationId !=null and req.locationId != ''">
,bis.type_id
</if>
<if test="req.typeId != null and req.typeId != ''">
,bis.size_id
</if>
<if test="req.sizeId !=null and req.sizeId != ''">
,bis.unit_price
</if>
</select>
<delete id="deleteByCabinet" parameterType="java.lang.String">
delete from base_inventory_summary where locationId = #{cabinetId}
</delete>
<update parameterType="java.lang.String" id="id">
UPDATE vie_price_sum_summary
SET
add_price = CASE
WHEN add_price IS NULL THEN start_price - end_price
ELSE add_price
END,
add_num = CASE
WHEN add_num IS NULL THEN start_num - end_num
ELSE add_num
END
WHERE add_price IS NULL OR add_num IS NULL;
</update>
<insert id="setWarrantyInventoryAction" statementType="CALLABLE">
{CALL Insert_into_base_warranty_inventory()}
</insert>
<insert id="setDestoryGroupAction" statementType="CALLABLE">
{CALL Insert_into_view_destory_group()}
</insert>
<insert id="setWarrantyGroupAction" statementType="CALLABLE">
{CALL Insert_into_view_warranty_group()}
</insert>
<insert id="getSumByCabinet">
INSERT INTO base_inventory_summary (id,org_id_int,org_name,type_id, type_name,size_id,size_name,location_id,location_name,
number,unit_price,price,stock_number, outbound_number,destruction_number,expire_number,
broken_number,use_number,fix_number,location_type,create_time,update_time)
select
MAX(t.id) as id,t.orgId,t.orgName,t.type_id,t.typeName,t.size_id,t.sizeName,t.locationId,t.locationName,sum(t.number) as number,
t.unitPrice,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,
sum(t.destructionNumber)as destructionNumber,sum(t.expireNumber)as expireNumber,sum(t.brokenNumber)as brokenNumber,
sum(t.useNumber)as useNumber,sum(t.fixNumber)as fixNumber,t.location_type,NOW(),NOW()
FROM
(SELECT
UUID() as id,
bi.org_id_int as orgId,
po.org_name as orgName,
bcb.cabinet_id as locationId,
bi.location_id as locationBoxId,
bc.name as locationName,
bi.type_id,
t.name as typeName,
bi.size_id,
s.name as sizeName,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)+SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) as number,
bi.price as unitPrice,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &gt; NOW() then 1 else 0 end )as expireNumber,
sum(case when bi.state ='broken' and bi.location_state='in' then 1 else 0 end)as brokenNumber,
sum(case when bi.bussiness_state = 'borrow' and bi.location_state='out' then 1
when bi.bussiness_state = 'take' and bi.location_state='out' then 1 else 0 end)as useNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &lt; NOW()
and DATEDIFF(DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH),NOW()) &lt; #{brokenNumberDays} then 1 else 0 end)as fixNumber,
bi.location_type
FROM base_inventory bi
join base_cabinet_box bcb on bi.location_id = bcb.id
join base_cabinet bc on bcb.cabinet_id = bc.id
join base_equipment_type t on t.id = bi.type_id
join base_equipment_size s on s.id = bi.size_id
join pub_org po on bi.org_id_int = po.org_id
WHERE location_type = 1 and bcb.cabinet_id=#{cabinetId}
GROUP BY location_id, type_id,size_id,bi.org_id_int,bi.price ) as t
GROUP BY t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice
</insert>
<select id="getTotalNumberAndPrice" resultType="com.junmp.jyzb.entity.InventorySummary">
select sum(is.number) as number,sum(is.price)as price,
sum(is.stock_number)as stockNumber,sum(is.stock_number * unit_price) as stockNumberPrice,
sum(is.outbound_number)as outboundNumber,sum(is.outbound_number * unit_price) as outboundNumberPrice,
sum(is.destruction_number)as destructionNumber,sum(is.destruction_number * unit_price) as destructionNumberPrice,
sum(is.expire_number)as expireNumber,sum(is.expire_number * unit_price) as expireNumberPrice,
sum(is.broken_number)as brokenNumber,sum(is.broken_number * unit_price) as brokenNumberPrice
<if test="req.orgId != null and req.orgId != ''">
,is.org_id_int as orgId
</if>
<if test="req.locationId !=null and req.locationId != ''">
,is.location_id as locationId
</if>
<if test="req.locationType != null and req.locationType != ''">
,is.location_type as locationType
</if>
FROM base_inventory_summary `is`
join base_equipment_type et on is.type_id=et.id
where 1=1
<if test="req.typeIds !=null and req.typeIds.size()>0">
and (
<foreach collection="req.typeIds" item="item" open="(" separator="or" close=")">
et.id=#{item} or et.parent_ids like CONCAT('%', #{item}, '%')
</foreach>
)
</if>
<if test="req.orgId != null and req.orgId != ''">
and is.org_id_int=#{req.orgId}
</if>
<if test="req.locationId !=null and req.locationId != ''">
and is.location_id=#{req.locationId}
</if>
<if test="req.sizeId != null and req.sizeId != ''">
and is.size_id=#{req.sizeId}
</if>
<if test="req.TypeId != null and req.typeId != ''">
and is.type_id=#{req.typeId}
</if>
<if test="req.locationType != null and req.locationType != ''">
and is.location_type=#{req.locationType}
</if>
<choose>
<when test="req.number != null and req.number != ''">
<if test="req.number.charAt(0) == '='">
AND is.number = SUBSTRING(#{req.number}, 2)
</if>
<if test="req.number.charAt(0) == '&lt;'">
AND is.number &lt; SUBSTRING(#{req.number}, 2)
</if>
<if test="req.number.charAt(0) == '&gt;'">
AND is.number &gt; SUBSTRING(#{req.number}, 2)
</if>
</when>
</choose>
<choose>
<when test="req.stockNumber != null and req.stockNumber != ''">
<if test="req.stockNumber.charAt(0) == '='">
AND is.stock_number = SUBSTRING(#{req.stockNumber}, 2)
</if>
<if test="req.stockNumber.charAt(0) == '&lt;'">
AND is.stock_number &lt; SUBSTRING(#{req.stockNumber}, 2)
</if>
<if test="req.stockNumber.charAt(0) == '&gt;'">
AND is.stock_number &gt; SUBSTRING(#{req.stockNumber}, 2)
</if>
</when>
</choose>
<choose>
<when test="req.outboundNumber != null and req.outboundNumber != ''">
<if test="req.outboundNumber.charAt(0) == '='">
AND is.outbound_number = SUBSTRING(#{req.outboundNumber}, 2)
</if>
<if test="req.outboundNumber.charAt(0) == '&lt;'">
AND is.outbound_number &lt; SUBSTRING(#{req.outboundNumber}, 2)
</if>
<if test="req.outboundNumber.charAt(0) == '&gt;'">
AND is.outbound_number &gt; SUBSTRING(#{req.outboundNumber}, 2)
</if>
</when>
</choose>
<choose>
<when test="req.expireNumber != null and req.expireNumber != ''">
<if test="req.expireNumber.charAt(0) == '='">
AND is.expire_number = SUBSTRING(#{req.expireNumber}, 2)
</if>
<if test="req.expireNumber.charAt(0) == '&lt;'">
AND is.expire_number &lt; SUBSTRING(#{req.expireNumber}, 2)
</if>
<if test="req.expireNumber.charAt(0) == '&gt;'">
AND is.expire_number &gt; SUBSTRING(#{req.expireNumber}, 2)
</if>
</when>
</choose>
<choose>
<when test="req.brokenNumber != null and req.brokenNumber != ''">
<if test="req.brokenNumber.charAt(0) == '='">
AND is.broken_number = SUBSTRING(#{req.brokenNumber}, 2)
</if>
<if test="req.brokenNumber.charAt(0) == '&lt;'">
AND is.broken_number &lt; SUBSTRING(#{req.brokenNumber}, 2)
</if>
<if test="req.brokenNumber.charAt(0) == '&gt;'">
AND is.broken_number &gt; SUBSTRING(#{req.brokenNumber}, 2)
</if>
</when>
</choose>
<choose>
<when test="req.unitPrice != null and req.unitPrice != ''">
<if test="req.unitPrice.charAt(0) == '='">
AND is.unit_price = SUBSTRING(#{req.unitPrice}, 2)
</if>
<if test="req.unitPrice.charAt(0) == '&lt;'">
AND is.unit_price &lt; SUBSTRING(#{req.unitPrice}, 2)
</if>
<if test="req.unitPrice.charAt(0) == '&gt;'">
AND is.unit_price &gt; SUBSTRING(#{req.unitPrice}, 2)
</if>
</when>
</choose>
<choose>
<when test="req.price != null and req.price != ''">
<if test="req.price.charAt(0) == '='">
AND is.price = SUBSTRING(#{req.price}, 2)
</if>
<if test="req.price.charAt(0) == '&lt;'">
AND is.price &lt; SUBSTRING(#{req.price}, 2)
</if>
<if test="req.price.charAt(0) == '&gt;'">
AND is.price &gt; SUBSTRING(#{req.price}, 2)
</if>
</when>
</choose>
</select>
<select id="EquipmentStatistics" resultType="com.junmp.jyzb.entity.InventorySummary"
parameterType="com.junmp.jyzb.api.bean.query.InventorySumReq">
select sum(number) as number,sum(price)as price,sum(stock_number)as stockNumber,
sum(outbound_number)as outboundNumber,sum(destruction_number)as destructionNumber,
sum(expire_number)as expireNumber,sum(broken_number)as brokenNumber,
sum(fix_number)as fixNumber,sum(use_number)as useNumber
FROM base_inventory_summary where org_id_int=#{req.orgId}
</select>
<select id="selectByEqs" resultType="com.junmp.jyzb.entity.InventorySummary">
SELECT sum(stock_number) as stockNumber,size_id as sizeId,type_id as typeId,MAX(size_name) as sizeName,
MAX(type_name) as typeName,org_id_int as orgId,MAX(org_name) as orgName
FROM base_inventory_summary where org_id_int=#{orgId}
GROUP BY size_id,type_id
HAVING stockNumber>0
</select>
<select id="selectSumByItems" resultType="com.junmp.jyzb.entity.InventorySummary">
select id,valuekey,org_id_int as org_id,org_name,org_code,type_id,type_name,size_id,size_name,location_id,location_name,location_type,
number,unit_price,price,stock_number,outbound_number,destruction_price,destruction_number,expire_number,expire_price,
broken_price,broken_number,fix_price,fix_number,use_number,agent_broken_num,fix_count,use_count,create_time,update_time,threshold,property
from base_inventory_summary where
<foreach collection="list" item="item" separator="or">
(
org_id_int = ${item[0]} AND location_id = '${item[1]}' AND type_id = ${item[2]} AND size_id = '${item[3]}'
AND unit_price = ${item[4]}
)
</foreach>
</select>
<select id="selectSum" resultType="com.junmp.jyzb.entity.InventorySummary">
select id,valuekey,org_id_int as org_id,org_name,org_code,type_id,type_name,size_id,size_name,location_id,location_name,location_type,
number,unit_price,price,stock_number,outbound_number,destruction_price,destruction_number,expire_number,expire_price,
broken_price,broken_number,fix_price,fix_number,use_number,agent_broken_num,fix_count,use_count,create_time,update_time,threshold,property
from base_inventory_summary where
<foreach collection="list" item="item" separator="or">
(
org_id_int = ${item[0]} AND location_id = '${item[1]}' AND type_id = ${item[2]} AND size_id = '${item[3]}'
AND unit_price = ${item[4]}
and property=${item[5]}
)
</foreach>
</select>
<select id="getByOrgId" resultType="com.junmp.jyzb.api.bean.dto.TjDto.TjOrgEqsDto"
parameterType="java.lang.Long">
select * from view_orgeqs_sum where org_id=#{orgId} or parent_id=#{orgId}
</select>
<select id="getEqsByOrgId" resultType="com.junmp.jyzb.api.bean.dto.EqsSumDto">
SELECT type_id,max(type_name) as type_name,org_id_int as org_id,max(org_name) as org_name,
<if test="sizeId !=null and sizeId != ''">
size_id,max(size_name) as size_name,
</if>
(sum((case when (`its`.`location_type` = 0) then `its`.`stock_number` else 0 end))+sum((case when (`its`.`location_type` = 0) then `its`.`outbound_number` else 0 end))+sum((case when (`its`.`location_type` = 0) then `its`.`destruction_number` else 0 end))) as number,
sum((case when (`its`.`location_type` = 0) then `its`.`stock_number` else 0 end)) AS `ck_stock_number`,
sum((case when (`its`.`location_type` = 0) then `its`.`outbound_number` else 0 end)) AS `ck_outbound_number`,
sum((case when (`its`.`location_type` = 0) then `its`.`destruction_number` else 0 end)) AS `destruction_number`,
sum((case when (`its`.`location_type` = 1) then `its`.`stock_number` else 0 end)) AS `djg_stock_number`,
sum((case when (`its`.`location_type` = 1) then `its`.`outbound_number` else 0 end)) AS `djg_outbound_number`
FROM `base_inventory_summary_type2` its
where org_id_int IN
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<if test="typeId !=null and typeId != ''">
and type_id=#{typeId}
</if>
<if test="sizeId !=null and sizeId != ''">
and size_id=#{sizeId}
</if>
GROUP BY org_id_int,type_id
<if test="sizeId !=null and sizeId != ''">
,size_id
</if>
</select>
<select id="test" resultType="com.junmp.jyzb.api.bean.dto.TjDto.TjOrgEqsDto" statementType="CALLABLE">
{CALL view_sum_total(#{req.typeId, mode=IN, jdbcType=VARCHAR})}
</select>
<select id="GetInvSum" resultType="com.junmp.jyzb.api.bean.dto.TjDto.TjOrgEqsDto" statementType="CALLABLE">
{CALL GetInventorySummary(#{orgId,mode=IN},#{typeId,mode=IN},#{sizeName,mode=IN})}
</select>
<select id="GetInvSelfSum" resultType="com.junmp.jyzb.api.bean.dto.TjDto.TjOrgEqsDto" statementType="CALLABLE">
{CALL GetInvSelfSummary(#{orgId,mode=IN},#{typeId,mode=IN},#{sizeName,mode=IN})}
</select>
<select id="GetSumLeve4" resultType="com.junmp.jyzb.api.bean.dto.TjDto.TjOrgEqsDto" statementType="CALLABLE">
{CALL GetSumLeve4(#{orgId,mode=IN},#{typeId,mode=IN},#{sizeName,mode=IN},#{sql,mode=IN})}
</select>
<select id="selectDynamicView" resultType="com.junmp.jyzb.api.bean.dto.TjDto.TjOrgEqsDto">
SELECT * FROM dynamic_view
</select>
<select id="selectViewOrgeqsSum" resultType="com.junmp.jyzb.api.bean.dto.TjDto.TjOrgEqsDto">
select * from view_orgeqs_sum
</select>
<delete id="deleteByWarehouse"
parameterType="com.junmp.jyzb.api.bean.dto.WarehouseDto">
delete from base_inventory_summary
where location_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</delete>
<insert id="getSumByWarehouse" >
INSERT INTO base_inventory_summary (id,org_id_int,org_name,location_id,location_name,type_id, type_name,size_id,
size_name,number,unit_price,price, stock_number, outbound_number,destruction_number,
expire_number,broken_number,use_number,fix_number,location_type,create_time,update_time)
select
MAX(t.id) as id,t.orgId,t.orgName,t.locationId,MAX(t.locationName),t.type_id,t.typeName,t.size_id,t.sizeName,
sum(t.number) as number,t.unitPrice,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,
sum(t.destructionNumber)as destructionNumber,sum(t.destructionNumber) as expireNumber,sum(t.brokenNumber) as brokenNumber,
sum(t.useNumber)as useNumber,sum(t.fixNumber)as fixNumber,t.location_type,NOW(),NOW()
FROM
(SELECT
UUID() as id,
bi.org_id_int as orgId,
po.org_name as orgName,
MAX(bi.location_id) as locationId,
MAX(bw.name) as locationName,
bi.type_id,
t.name as typeName,
bi.size_id,
s.name as sizeName,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)+SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) as number,
bi.price as unitPrice,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
SUM(CASE WHEN location_state = 'out' and bi.state!='destory' THEN 1 ELSE 0 END) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &gt; NOW() then 1 else 0 end )as expireNumber,
sum(case when bi.state ='broken' and bi.location_state='in' then 1 else 0 end)as brokenNumber,
sum(case when bi.bussiness_state = 'borrow' and bi.location_state='out' then 1
when bi.bussiness_state = 'take' and bi.location_state='out' then 1 else 0 end)as useNumber,
sum(case when bi.warranty_period=0 then 0 when DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH) &lt; NOW()
and DATEDIFF(DATE_ADD(bi.production_date,INTERVAL bi.warranty_period MONTH),NOW()) &lt; #{brokenNumberDays} then 1 else 0 end)as fixNumber,
bi.location_type
FROM base_inventory bi
join base_warehouse bw on bi.location_id = bw.id
join base_equipment_type t on t.id = bi.type_id
join base_equipment_size s on s.id = bi.size_id
join pub_org po on bi.org_id_int = po.org_id
WHERE location_type = 0
and bi.location_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
GROUP BY type_id,size_id,bi.org_id_int,location_id,bi.price) as t
GROUP BY t.locationId,t.type_id,t.size_id,t.orgId,t.unitPrice
</insert>
<insert id="insertToSummary" statementType="CALLABLE">
{call InsertInventorySummary(
#{summaryTableName, mode=IN},
#{sourceTableName, mode=IN},
#{warrantyThreshold, mode=IN, jdbcType=INTEGER}
)}
</insert>
<insert id="useViewOrgeqs" statementType="CALLABLE">
{CALL view_orgeqs(#{sql,mode=IN},#{orgId,mode=IN},#{sql1,mode=IN})}
</insert>
<insert id="useViewOrgIdInSubordinate" parameterType="java.lang.String">
{CALL view_orgIdInSubordinate(#{sql,mode=IN})}
</insert>
<insert id="useViewOrgIdInLevel">
{CALL view_orgIdInLevel(#{sql,mode=IN},#{orgId,mode=IN})}
</insert>
<select id="getTotalData" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
`po`.`org_id` AS `org_id`
FROM `pub_org` `po`
LEFT JOIN `base_inventory_summary` `bis` ON `po`.`org_id` = `bis`.`org_id_int`
WHERE `po`.`del_flag` = 1
and (po.org_id=#{orgId} or `po`.org_parent_id=#{orgId})
and `po`.level_flag=(select level_flag FROM pub_org where org_id=#{orgId} )+1
GROUP BY org_id
</select>
<select id="getTotalDataDetail" resultType="com.junmp.jyzb.api.bean.dto.TjDto.TjOrgEqsDto">
SELECT
`po`.`org_id` AS `org_id`,
`po`.`org_code` AS `org_code`,
`po`.`org_parent_id` AS `parent_id`,
`po`.`org_name` AS `org_name`,
`po`.`level_flag` AS `level_flag`,
`po`.`d_name` AS `d_name`,
COALESCE (
sum(
CASE
WHEN ( `bis`.`location_type` = 0 ) THEN
`bis`.`stock_number` ELSE 0
END
) + sum(
CASE
WHEN ( `bis`.`location_type` = 0 ) THEN
`bis`.`outbound_number` ELSE 0
END
) +sum(
CASE
WHEN(`bis`.`location_type` = 1) then
`bis`.`stock_number` ELSE 0
END
)+SUM(
CASE
WHEN ( `bis`.`location_type` = 1 ) THEN
`bis`.`outbound_number` ELSE 0
END
),
0
) AS `total_number`,
COALESCE ( sum( CASE WHEN ( `bis`.`location_type` = 0 ) THEN `bis`.`stock_number` ELSE 0 END ), 0 ) AS `ck_stock_number`,
COALESCE ( sum( CASE WHEN ( `bis`.`location_type` = 0 ) THEN `bis`.`outbound_number` ELSE 0 END ), 0 ) AS `ck_outbound_number`,
COALESCE ( sum( CASE WHEN ( `bis`.`location_type` = 0 ) THEN `bis`.`destruction_number` ELSE 0 END ), 0 ) AS `destruction_number`,
COALESCE ( sum( CASE WHEN ( `bis`.`location_type` = 1 ) THEN `bis`.`stock_number` ELSE 0 END ), 0 ) AS `djg_stock_number`,
COALESCE ( sum( CASE WHEN ( `bis`.`location_type` = 1 ) THEN `bis`.`outbound_number` ELSE 0 END ), 0 ) AS `djg_outbound_number`
FROM `pub_org` `po`
LEFT JOIN `base_inventory_summary` `bis` ON `po`.`org_id` = `bis`.`org_id_int`
WHERE
`po`.`del_flag` = 1
<if test="level ==null" >
and (po.org_id =#{orgId} or (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')
<if test="levelNum !=0">
AND SUBSTRING(`po`.`org_code`, 5, 2) = '00'
</if>
))
and (`po`.level_flag>(select level_flag FROM pub_org where org_id=#{orgId} )+#{levelNum} or
`po`.level_flag=(select level_flag FROM pub_org where org_id=#{orgId} ))
</if>
<if test="level==1">
and (po.org_id !=#{orgId} and (`po`.org_parent_ids like CONCAT('%', #{orgId}, '%')
<if test="levelNum !=0">
AND SUBSTRING(`po`.`org_code`, 5, 2) = '00'
</if>
))
and (`po`.level_flag>(select level_flag FROM pub_org where org_id=#{orgId} )+#{levelNum} or
`po`.level_flag=(select level_flag FROM pub_org where org_id=#{orgId} ))
</if>
<if test="level == 0 ">
and po.org_id = #{orgId}
</if>
<if test="typeIdsList!=null and typeIdsList.size() > 0">
AND type_id IN
<foreach collection="typeIdsList " item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sizeNameList!=null and sizeNameList.size() > 0">
AND
<foreach collection="sizeNameList " item="item" open="(" separator="or" close=")">
size_name like CONCAT('%', #{item}, '%')
</foreach>
</if>
GROUP BY `po`.`org_id`,`po`.`org_code`,`po`.`org_parent_id`,`po`.`org_name`
<if test="column != null and column != '' and order != null and order != '' ">
order by ${column} ${order}
</if>
</select>
<select id="getSumByViewOrgeqsSum" resultType="com.junmp.jyzb.api.bean.dto.TjDto.FinalTjOrgEqsDto">
select sum(total_number) as total_number,
sum(ck_stock_number) as ck_stock_number,
sum(ck_outbound_number) as ck_outbound_number,
sum(destruction_number) as destruction_number,
sum(djg_stock_number) as djg_stock_number,
sum(djg_outbound_number) as djg_outbound_number
FROM view_orgeqs_sum
</select>
<select id="TjOrgEqsDetail" resultType="com.junmp.jyzb.api.bean.dto.InventorySumDto">
SELECT
type_name,
size_name,
type_id,
size_id,
(
sum( CASE WHEN `base_inventory_summary`.`location_type` = 0 THEN `base_inventory_summary`.`stock_number` ELSE 0 END ) +
sum( CASE WHEN `base_inventory_summary`.`location_type` = 0 THEN `base_inventory_summary`.`outbound_number` ELSE 0 END ) +
sum( CASE WHEN `base_inventory_summary`.`location_type` = 1 THEN `base_inventory_summary`.`stock_number` ELSE 0 END )+
sum( CASE WHEN `base_inventory_summary`.`location_type` = 1 THEN `base_inventory_summary`.`stock_number` ELSE 0 END )
) AS total_number,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 0 ) THEN `base_inventory_summary`.`stock_number` ELSE 0 END ) AS `ck_stock_number`,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 0 ) THEN `base_inventory_summary`.`outbound_number` ELSE 0 END ) AS `ck_outbound_number`,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 0 ) THEN `base_inventory_summary`.`destruction_number` ELSE 0 END ) AS `destruction_number`,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 1 ) THEN `base_inventory_summary`.`stock_number` ELSE 0 END ) AS `djg_stock_number`,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 1 ) THEN `base_inventory_summary`.`outbound_number` ELSE 0 END ) AS `djg_outbound_number`
FROM
base_inventory_summary
WHERE
org_id_int = #{orgId}
<if test="typeIdsList!=null and typeIdsList.size() > 0">
AND type_id IN
<foreach collection="typeIdsList " item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sizeNameList!=null and sizeNameList.size() > 0">
AND
<foreach collection="sizeNameList " item="item" open="(" separator="or" close=")">
size_name like CONCAT('%', #{item}, '%')
</foreach>
</if>
GROUP BY
type_id,
type_name,
size_name,
size_id
<if test="column != null and column != '' and order != null and order != '' ">
order by ${column} ${order}
</if>
<if test="column == null and order == null">
ORDER BY type_id
</if>
</select>
<select id="selectTotalNum" resultType="com.junmp.jyzb.api.bean.dto.InventorySumDto">
<foreach collection="list" item="item" separator="union all">
SELECT COALESCE(SUM(stock_number), 0) as stock_number,
COALESCE(type_id,${item[0]}) as type_id ,
COALESCE( size_id,'${item[1]}') as size_id
FROM base_inventory_summary
WHERE org_id_int = #{orgId} and (type_id = ${item[0]} AND size_id = '${item[1]}')
</foreach>
</select>
<select id="GetEquipmentSummarySum" resultType="java.lang.Integer"
parameterType="com.junmp.jyzb.api.bean.query.InventorySumReq">
select count(*) from (
SELECT
is.type_id,
is.type_name,
sum( is.number ) AS number,
sum( is.number * is.unit_price ) AS price,
sum( is.stock_number ) AS stock_number,
sum( is.stock_number * is.unit_price ) AS stock_number_price,
sum( is.outbound_number ) AS outbound_number,
sum( is.outbound_number * is.unit_price ) AS outbound_number_price,
sum( is.destruction_number ) AS destruction_number,
sum( is.destruction_number * is.unit_price ) AS destruction_number_price ,
sum( is.expire_number) as expire_number,
sum( is.expire_number * is.unit_price ) AS expire_number_price ,
sum( is.broken_number) as broken_number,
sum( is.broken_number * is.unit_price ) AS broken_number_price
FROM
base_inventory_summary `is`
join base_equipment_type et on is.type_id=et.id
WHERE
is.org_id_int = #{req.orgId}
<if test="req.typeIds !=null and req.typeIds.size()>0">
and (
<foreach collection="req.typeIds" item="item" open="(" separator="or" close=")">
et.id=#{item} or et.parent_ids like CONCAT('%', #{item}, '%')
</foreach>
)
</if>
<if test="req.locationType !='all' and req.locationType != null ">
and is.location_type=#{req.locationType}
</if>
<if test="req.locationId !=null and req.locationId !=''">
and is.location_id=#{req.locationId}
</if>
<if test="req.property !='all' and req.property != null">
and is.property=#{req.property}
</if>
GROUP BY
is.type_id,
is.type_name
ORDER BY
is.type_id
) as a
</select>
<select id="GetEquipmentSummary" resultType="com.junmp.jyzb.entity.InventorySummary">
SELECT
is.type_id,
is.type_name,
sum( is.number ) AS number,
sum( is.number * is.unit_price ) AS price,
sum( is.stock_number ) AS stock_number,
sum( is.stock_number * is.unit_price ) AS stock_number_price,
sum( is.outbound_number ) AS outbound_number,
sum( is.outbound_number * is.unit_price ) AS outbound_number_price,
sum( is.destruction_number ) AS destruction_number,
sum( is.destruction_number * is.unit_price ) AS destruction_number_price ,
sum( is.expire_number) as expire_number,
sum( is.expire_number * is.unit_price ) AS expire_number_price ,
sum( is.broken_number) as broken_number,
sum( is.broken_number * is.unit_price ) AS broken_number_price
FROM
base_inventory_summary `is`
join base_equipment_type et on is.type_id=et.id
WHERE
is.org_id_int = #{req.orgId}
<if test="req.typeIds !=null and req.typeIds.size()>0">
and (
<foreach collection="req.typeIds" item="item" open="(" separator="or" close=")">
et.id=#{item} or et.parent_ids like CONCAT('%', #{item}, '%')
</foreach>
)
</if>
<if test="req.locationType !='all' and req.locationType != null">
and is.location_type=#{req.locationType}
</if>
<if test="req.locationId !=null and req.locationId !=''">
and is.location_id=#{req.locationId}
</if>
<if test="req.property !='all' and req.property != null">
and is.property=#{req.property}
</if>
GROUP BY
is.type_id,
is.type_name
<if test="req.column != 'create_time' ">
order by ${req.column} ${req.order}
</if>
<if test="req.column == 'create_time' ">
order by is.type_id asc
</if>
<if test="pageNo != null and pageNo != '' and pageSize != null and pageSize != '' ">
limit #{pageNo},#{pageSize}
</if>
</select>
<select id="GetEquipmentSummaryDetail" resultType="com.junmp.jyzb.entity.InventorySummary"
parameterType="com.junmp.jyzb.api.bean.query.InventorySumReq">
SELECT
is.type_id,
is.type_name,
is.size_id,
is.size_name,
is.unit_price,
sum( is.number ) AS number,
sum( is.number * is.unit_price ) AS price,
sum( is.stock_number ) AS stock_number,
sum( is.stock_number * is.unit_price ) AS stock_number_price,
sum( is.outbound_number ) AS outbound_number,
sum( is.outbound_number * is.unit_price ) AS outbound_number_price,
sum( is.destruction_number ) AS destruction_number,
sum( is.destruction_number * is.unit_price ) AS destruction_number_price ,
sum( is.expire_number) as expire_number,
sum( is.expire_number * is.unit_price ) AS expire_number_price ,
sum( is.broken_number) as broken_number,
sum( is.broken_number * is.unit_price ) AS broken_number_price
FROM
base_inventory_summary `is`
WHERE
is.org_id_int = #{req.orgId} and is.type_id=#{req.typeId}
<if test="req.locationType !='all' and req.locationType != null">
and is.location_type=#{req.locationType}
</if>
<if test="req.locationId !=null and req.locationId !=''">
and is.location_id=#{req.locationId}
</if>
<if test="req.property !=null and req.property !='all'">
and is.property=#{req.property}
</if>
GROUP BY
is.type_id,
is.type_name,
is.size_id,
is.size_name,
is.unit_price
<if test="req.column != null and req.column != '' and req.order != null and req.order != '' ">
order by ${req.column} ${req.order}
</if>
</select>
<select id="selectSumByItemsCount" resultType="java.lang.Integer"
parameterType="com.junmp.jyzb.api.bean.query.InventoryReq">
select count(*) from (
SELECT wi.type_id,wi.size_id,wi.shelf_id,wi.shelf_location, wi.epc,wi.org_id,wi.location_state,wi.location_name,wi.type_name,wi.size_name,wi.org_name,
wi.location_type,wi.location_id,i.id,i.supplier_id,i.price,i.state,i.bussiness_state,
i.production_date,i.warranty_period,i.maintenance_period, i.term_state,i.property,
i.area_id,
bs.name as supplier_name,
(select instructions FROM base_equipment_type where id=#{req.typeId}) as instructions,
(select photo FROM base_equipment_type where id=#{req.typeId}) as type_photo,
es.photo as size_photo
FROM base_warehouse_inventory wi
LEFT JOIN base_inventory i ON i.epc = wi.epc
LEFT JOIN base_equipment_size es ON wi.size_id = es.id
LEFT JOIN base_supplier bs ON bs.id = i.supplier_id
WHERE wi.org_id=#{req.orgId} and wi.type_id=#{req.typeId} and i.state !="destory"
<if test="req.locationType !='all' and req.locationType != null">
and wi.location_type=#{req.locationType}
</if>
<if test="req.locationId != null and req.locationId != ''">
and wi.location_id =#{req.locationId}
</if>
<if test="req.termState!= -1">
and i.term_state=#{req.termState}
</if>
<if test="req.locationState!='all' and req.locationState !=null and req.locationState!=''">
and i.location_state=#{req.locationState}
</if>
<if test="req.sizeId !=null and req.sizeId != ''">
and wi.size_id=#{req.sizeId}
</if>
<if test="req.price !=null and req.price != ''">
and i.price=#{req.price}
</if>
<if test="req.warrantyPeriod != null and req.warrantyPeriod != ''">
and i.warranty_period=#{req.warrantyPeriod}
</if>
<if test="req.maintenancePeriod != null and req.maintenancePeriod != ''">
and i.maintenance_period=#{req.maintenancePeriod}
</if>
ORDER BY wi.type_id,i.size_id
) as a
</select>
<select id="GetDetailByTerms" resultType="com.junmp.jyzb.api.bean.dto.InventoryDto">
SELECT wi.type_id,wi.size_id,wi.shelf_id,wi.shelf_location, wi.epc,wi.org_id,wi.location_state,wi.location_name,wi.type_name,wi.size_name,wi.org_name,
wi.location_type,wi.location_id,i.id,i.supplier_id,i.price,i.state,i.bussiness_state,
i.production_date,i.warranty_period,i.maintenance_period, i.term_state,i.property,
i.area_id,
bs.name as supplier_name,
(select instructions FROM base_equipment_type where id=#{req.typeId}) as instructions,
(select photo FROM base_equipment_type where id=#{req.typeId}) as type_photo,
es.photo as size_photo
FROM base_warehouse_inventory wi
LEFT JOIN base_inventory i ON i.epc = wi.epc
LEFT JOIN base_equipment_size es ON wi.size_id = es.id
LEFT JOIN base_supplier bs ON bs.id = i.supplier_id
<<<<<<< HEAD
LEFT JOIN base_cabinet_box bcb ON i.location_id = bcb.id AND i.location_type = 1
LEFT JOIN base_cabinet bc ON bcb.cabinet_id = bc.id
LEFT JOIN base_warehouse bw ON i.location_id = bw.id AND i.location_type = 0
WHERE wi.org_id=#{req.orgId} and wi.type_id=#{req.typeId}
-- SELECT //修改后应该按照这个来
-- wi.type_id,
-- wi.size_id,
-- wi.shelf_id,
-- wi.shelf_location,
-- wi.epc,
-- wi.org_id,
-- wi.location_state,
-- wi.location_type,
-- wi.location_id,
-- i.id,
-- i.supplier_id,
-- i.price,
-- i.state,
-- i.bussiness_state,
-- i.production_date,
-- i.warranty_period,
-- i.maintenance_period,
-- i.term_state,
-- i.property,
-- i.area_id,
-- wi.type_name AS type_name,
-- wi.size_name AS size_name,
-- wi.org_name AS org_name,
-- bs.NAME AS supplier_name,
-- wi.location_name AS location_name
-- FROM
-- base_warehouse_inventory wi
-- LEFT JOIN base_inventory i ON i.epc = wi.epc
-- LEFT JOIN base_supplier bs ON bs.id = i.supplier_id
=======
WHERE wi.org_id=#{req.orgId} and wi.type_id=#{req.typeId} and i.state !="destory"
>>>>>>> 7952b8c429b94cc118c5a5dda061f62585a8cdda
<if test="req.locationType !='all' and req.locationType != null">
and wi.location_type=#{req.locationType}
</if>
<if test="req.locationId != null and req.locationId != ''">
and wi.location_id =#{req.locationId}
</if>
<if test="req.termState!= -1">
and i.term_state=#{req.termState}
</if>
<if test="req.locationState!='all' and req.locationState !=null and req.locationState!=''">
and i.location_state=#{req.locationState}
</if>
<if test="req.sizeId !=null and req.sizeId != ''">
and wi.size_id=#{req.sizeId}
</if>
<if test="req.price !=null and req.price != ''">
and i.price=#{req.price}
</if>
<if test="req.warrantyPeriod != null and req.warrantyPeriod != ''">
and i.warranty_period=#{req.warrantyPeriod}
</if>
<if test="req.maintenancePeriod != null and req.maintenancePeriod != ''">
and i.maintenance_period=#{req.maintenancePeriod}
</if>
ORDER BY wi.type_id,i.size_id
<if test="pageNo != null and pageNo != '' and pageSize != null and pageSize != '' ">
limit #{pageNo},#{pageSize}
</if>
</select>
<select id="selectOrgIds" resultType="java.lang.Long">
SELECT
`po`.`org_id` AS `org_id`
FROM `pub_org` `po`
WHERE `po`.`del_flag` = 1
and (po.org_id=#{orgId} or `po`.org_parent_id=#{orgId})
and `po`.level_flag=(select level_flag FROM pub_org where org_id=#{orgId} )+1
GROUP BY org_id
</select>
</mapper>
\ No newline at end of file
...@@ -92,6 +92,7 @@ ...@@ -92,6 +92,7 @@
where ls.org_id = #{orgId} where ls.org_id = #{orgId}
and ls.location_type = 0) as b and ls.location_type = 0) as b
</select> </select>
<select id="ShowInOutRecordsByItemsCount" resultType="com.junmp.jyzb.entity.LogSummary"> <select id="ShowInOutRecordsByItemsCount" resultType="com.junmp.jyzb.entity.LogSummary">
select sum(a.number) as number from ( select sum(a.number) as number from (
select number from base_log_summary ls where location_type=#{req.locationType} select number from base_log_summary ls where location_type=#{req.locationType}
...@@ -111,7 +112,7 @@ ...@@ -111,7 +112,7 @@
and location_id=#{req.locationId} and location_id=#{req.locationId}
</if> </if>
<if test="req.userName != null and req.userName !=''"> <if test="req.userName != null and req.userName !=''">
and user_name=#{req.userName} and user_name like CONCAT('%', #{req.userName}, '%')
</if> </if>
<if test="req.startTime != null and req.startTime != ''"> <if test="req.startTime != null and req.startTime != ''">
and use_time &gt;= #{req.startTime} and use_time &gt;= #{req.startTime}
...@@ -120,117 +121,91 @@ ...@@ -120,117 +121,91 @@
and use_time &lt;= #{req.endTime} and use_time &lt;= #{req.endTime}
</if> </if>
<if test="req.typeName != null and req.typeName !=''"> <if test="req.typeName != null and req.typeName !=''">
and epuipment_list like concat('%',#{req.typeName},'%') and equipment_List like concat('%',#{req.typeName},'%')
</if> </if>
<if test="req.column != null and req.column != '' and req.order != null and req.order != '' "> <if test="req.column != null and req.column != '' and req.order != null and req.order != '' ">
order by ${req.column} ${req.order} order by ${req.column} ${req.order}
</if> </if>
) as a ) as a
</select> </select>
<select id="RecordSumByOrderId" resultType="com.junmp.jyzb.api.bean.dto.LogSummaryDto"> <select id="RecordSumByOrderId" resultType="com.junmp.jyzb.api.bean.dto.LogSummaryDto">
select t.* from (
(SELECT
ls.order_code,
ls.order_main_id,
GROUP_CONCAT(DISTINCT COALESCE (NULLIF( ls.device_type, '' ))) AS device_type,
GROUP_CONCAT(DISTINCT COALESCE (NULLIF( ls.user_name, '' ))) AS user_name,
GROUP_CONCAT(DISTINCT COALESCE (NULLIF( ls.equipment_list, '' ))) AS equipment_list,
GROUP_CONCAT(DISTINCT COALESCE (NULLIF( ls.location_name, '' ))) AS location_name,
ls.bussiness_type,
ls.out_in_state,
sum(number) as number
FROM
base_log_summary ls
where ls.order_main_id is not null or ls.order_main_id !='' and ls.org_id=#{req.orgId}
and ls.create_time>#{req.startTime} and ls.create_time &lt; #{req.endTime} and ls.location_type=0
GROUP BY ls.order_main_id,ls.order_code,ls.bussiness_type,ls.out_in_state)
union all (
SELECT SELECT
ls.order_code, max(order_code) as order_code,
ls.order_main_id, order_main_id,
device_type, GROUP_CONCAT(DISTINCT COALESCE (NULLIF( device_type, '' ))) AS device_type,
user_name, GROUP_CONCAT(DISTINCT COALESCE (NULLIF( user_name, '' ))) AS user_name,
equipment_list, GROUP_CONCAT(DISTINCT COALESCE (NULLIF( equipment_list, '' ))) AS equipment_list,
location_name, GROUP_CONCAT(DISTINCT COALESCE (NULLIF( location_name, '' ))) AS location_name,
ls.bussiness_type, bussiness_type,
ls.out_in_state, out_in_state,
number sum(number) as number
FROM FROM
base_log_summary ls base_log_summary
where ls.order_main_id is null or ls.order_main_id ='' and ls.org_id=#{req.orgId} where (order_main_id is not null and order_main_id !='') and org_id=#{req.orgId}
and ls.create_time>#{req.startTime} and ls.create_time &lt; #{req.endTime} and ls.location_type=0 and create_time>#{req.startTime} and create_time &lt; #{req.endTime} and location_type=0
)) as t
having 1=1
<if test="req.outInState != null and req.outInState != ''"> <if test="req.outInState != null and req.outInState != ''">
and t.out_in_state =#{req.outInState} and out_in_state =#{req.outInState}
</if> </if>
<if test="req.bussinessType != null and req.bussinessType != ''"> <if test="req.bussinessType != null and req.bussinessType != ''">
and t.bussiness_type =#{req.bussinessType} and bussiness_type =#{req.bussinessType}
</if> </if>
<if test="req.locationName != null and req.locationName != ''"> <if test="req.locationName != null and req.locationName != ''">
and t.location_name =#{req.locationName} and location_name like CONCAT('%', #{req.locationName}, '%')
</if>
<if test="req.locationId != null and req.locationId != ''">
and location_id =#{req.locationId}
</if> </if>
<if test="req.typeName != null and req.typeName != ''"> <if test="req.typeName != null and req.typeName != ''">
and t.equipment_list =#{req.equipmentList} and equipment_list like CONCAT('%', #{req.typeName}, '%')
</if> </if>
<if test="req.userName != null and req.userName != ''"> <if test="req.userName != null and req.userName != ''">
and t.user_name =#{req.userName} and user_name like CONCAT('%', #{req.userName}, '%')
</if> </if>
GROUP BY order_main_id,bussiness_type,out_in_state
<if test="req.column != 'create_time' and req.column != null and req.column != '' and req.order != null and req.order != '' "> <if test="req.column != 'create_time' and req.column != null and req.column != '' and req.order != null and req.order != '' ">
order by ${req.column} ${req.order} order by ${req.column} ${req.order}
</if> </if>
<if test="pageNo != null and pageNo != '' and pageSize != null and pageSize != '' "> <if test="pageNo != null and pageNo != '' and pageSize != null and pageSize != '' ">
limit #{pageNo},#{pageSize} limit #{pageNo},#{pageSize}
</if> </if>
</select> </select>
<select id="RecordSumByOrderIdSum" resultType="com.junmp.jyzb.api.bean.dto.LogSummaryDto"> <select id="RecordSumByOrderIdSum" resultType="com.junmp.jyzb.api.bean.dto.LogSummaryDto">
select sum(number) as number,count(*) as count FROM ( select sum(number) as number,count(*) as count FROM (
select t.* FROM(
(SELECT
ls.order_code,
ls.order_main_id,
GROUP_CONCAT(DISTINCT COALESCE (NULLIF( ls.device_type, '' ))) AS device_type,
GROUP_CONCAT(DISTINCT COALESCE (NULLIF( ls.user_name, '' ))) AS user_name,
GROUP_CONCAT(DISTINCT COALESCE (NULLIF( ls.equipment_list, '' ))) AS equipment_list,
GROUP_CONCAT(DISTINCT COALESCE (NULLIF( ls.location_name, '' ))) AS location_name,
ls.bussiness_type,
sum(number) as number
FROM
base_log_summary ls
where ls.order_main_id is not null or ls.order_main_id !='' and ls.org_id=#{req.orgId}
and ls.create_time>#{req.startTime} and ls.create_time &lt; #{req.endTime} and ls.location_type=0
GROUP BY ls.order_main_id,ls.order_code,ls.bussiness_type)
union all (
SELECT SELECT
ls.order_code, max(order_code) as order_code,
ls.order_main_id, order_main_id,
device_type, GROUP_CONCAT(DISTINCT COALESCE (NULLIF( device_type, '' ))) AS device_type,
user_name, GROUP_CONCAT(DISTINCT COALESCE (NULLIF( user_name, '' ))) AS user_name,
equipment_list, GROUP_CONCAT(DISTINCT COALESCE (NULLIF( equipment_list, '' ))) AS equipment_list,
location_name, GROUP_CONCAT(DISTINCT COALESCE (NULLIF( location_name, '' ))) AS location_name,
ls.bussiness_type, bussiness_type,
number out_in_state,
sum(number) as number
FROM FROM
base_log_summary ls base_log_summary
where ls.order_main_id is null or ls.order_main_id ='' and ls.org_id=#{req.orgId} where (order_main_id is not null and order_main_id !='') and org_id=#{req.orgId}
and ls.create_time>#{req.startTime} and ls.create_time &lt; #{req.endTime} and ls.location_type=0 and create_time>#{req.startTime} and create_time &lt; #{req.endTime} and location_type=0
)) as t
having 1=1
<if test="req.outInState != null and req.outInState != ''"> <if test="req.outInState != null and req.outInState != ''">
and t.out_in_state =#{req.outInState} and out_in_state =#{req.outInState}
</if> </if>
<if test="req.bussinessType != null and req.bussinessType != ''"> <if test="req.bussinessType != null and req.bussinessType != ''">
and t.bussiness_type =#{req.bussinessType} and bussiness_type =#{req.bussinessType}
</if> </if>
<if test="req.locationName != null and req.locationName != ''"> <if test="req.locationName != null and req.locationName != ''">
and t.location_name =#{req.locationName} and location_name like CONCAT('%', #{req.locationName}, '%')
</if>
<if test="req.locationId != null and req.locationId != ''">
and location_id =#{req.locationId}
</if> </if>
<if test="req.typeName != null and req.typeName != ''"> <if test="req.typeName != null and req.typeName != ''">
and t.equipment_list =#{req.equipmentList} and equipment_list like CONCAT('%', #{req.typeName}, '%')
</if> </if>
<if test="req.userName != null and req.userName != ''"> <if test="req.userName != null and req.userName != ''">
and t.user_name =#{req.userName} and user_name like CONCAT('%', #{req.userName}, '%')
</if> </if>
GROUP BY order_main_id,bussiness_type,out_in_state
) as a ) as a
</select> </select>
......
...@@ -36,13 +36,13 @@ knife4j: ...@@ -36,13 +36,13 @@ knife4j:
spring: spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.1.128:3306/db_jyzb?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT&nullCatalogMeansCurrent=true url: jdbc:mysql://192.168.1.128:3306/db_jyzb_test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT&nullCatalogMeansCurrent=true
username: root username: root
password: 123456 password: 123456
redis: redis:
#host: 192.168.3.188 #host: 192.168.3.188
host: 192.168.3.121 host: 192.168.3.188
port: 6379 port: 6379
database: 1 database: 1
password: password:
......
...@@ -33,7 +33,7 @@ spring: ...@@ -33,7 +33,7 @@ spring:
virtual-host: / virtual-host: /
profiles: profiles:
#@spring.active@ #@spring.active@
active: local active: prod
servlet: servlet:
multipart: multipart:
max-request-size: 500MB max-request-size: 500MB
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论