数据接口
This commit is contained in:
parent
82dc799db3
commit
4670572a41
|
|
@ -68,7 +68,7 @@ public class PaTypeController {
|
|||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("deleteTypeData")
|
||||
@PostMapping("deleteTypeData")
|
||||
@DecryptAndVerify(decryptedClass = PaTypeVo.class)
|
||||
public ServerResponse deleteTypeData(EncryptedReq<PaTypeVo> dto) {
|
||||
return service.deleteTypeData(dto.getData());
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ public class PartInputDetails {
|
|||
/**
|
||||
* 单个价格
|
||||
*/
|
||||
private Decimal partPrice;
|
||||
private String partPrice;
|
||||
/**
|
||||
* 总价格
|
||||
*/
|
||||
private Decimal totalPrice;
|
||||
private String totalPrice;
|
||||
|
||||
/**
|
||||
* 厂家id
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class PartInputVo {
|
|||
/**
|
||||
* 总金额
|
||||
*/
|
||||
private Decimal allPrice;
|
||||
private String allPrice;
|
||||
/**
|
||||
* 入库数量
|
||||
*/
|
||||
|
|
@ -63,6 +63,8 @@ public class PartInputVo {
|
|||
*/
|
||||
private String startDay;
|
||||
|
||||
private String inputUser;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bonus.gzgqj.business.bases.mapper;
|
||||
|
||||
import com.bonus.gzgqj.business.bases.entity.PartInputDetails;
|
||||
import com.bonus.gzgqj.business.bases.entity.PartInputVo;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -10,4 +12,24 @@ import java.util.List;
|
|||
*/
|
||||
public interface PartInputMapper {
|
||||
List<PartInputVo> findByPage(PartInputVo data);
|
||||
|
||||
/**
|
||||
* 查询今日入库数量
|
||||
* @return
|
||||
*/
|
||||
int getInputNum();
|
||||
|
||||
/**
|
||||
* 新增 入库数据
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
int addInputData(PartInputVo vo);
|
||||
|
||||
/**
|
||||
* 新增入库
|
||||
* @param vo
|
||||
* @param list
|
||||
*/
|
||||
int addDetails(@Param("param") PartInputVo vo,@Param("list") List<PartInputDetails> list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class PaTypeServiceImpl implements PaTypeService{
|
|||
}else{
|
||||
int nums=mapper.updateTypeData(data);
|
||||
if(nums>0){
|
||||
return ServerResponse.createSuccess("修改成功");
|
||||
return ServerResponse.createSuccess("修改成功",data);
|
||||
}else{
|
||||
return ServerResponse.createErroe("修改失败");
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ public class PaTypeServiceImpl implements PaTypeService{
|
|||
int id=data.getId();
|
||||
if(id>0){
|
||||
List<String> idList=mapper.getChildList(data.getId());
|
||||
if(idList!=null && !idList.isEmpty()){
|
||||
if(idList==null || idList.isEmpty()){
|
||||
int num= mapper.deleteTypeData(data);
|
||||
if(num>0){
|
||||
return ServerResponse.createSuccess("删除成功");
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.bonus.gzgqj.business.bases.entity.PartInputDetails;
|
||||
import com.bonus.gzgqj.business.bases.entity.PartInputVo;
|
||||
import com.bonus.gzgqj.business.bases.mapper.PartInputMapper;
|
||||
import com.bonus.gzgqj.business.plan.entity.ProOutInfoVo;
|
||||
import com.bonus.gzgqj.business.plan.entity.FileUploadVo;
|
||||
import com.bonus.gzgqj.business.utils.FileUploadService;
|
||||
import com.bonus.gzgqj.manager.common.util.DateTimeHelper;
|
||||
import com.bonus.gzgqj.manager.common.util.StringHelper;
|
||||
import com.bonus.gzgqj.manager.common.util.StringUtils;
|
||||
import com.bonus.gzgqj.manager.common.util.UserUtil;
|
||||
import com.bonus.gzgqj.manager.webResult.ServerResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -14,8 +17,11 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* 配件入库 业务层
|
||||
|
|
@ -27,6 +33,8 @@ public class PartInputServiceImpl implements PartInputService{
|
|||
|
||||
@Autowired
|
||||
private PartInputMapper mapper;
|
||||
@Autowired
|
||||
private FileUploadService uploadService;
|
||||
/**
|
||||
* 分页查询配件入库
|
||||
* @param data
|
||||
|
|
@ -59,7 +67,7 @@ public class PartInputServiceImpl implements PartInputService{
|
|||
try{
|
||||
String params=request.getParameter("params");
|
||||
PartInputVo vo= JSON.parseObject(params,PartInputVo.class);
|
||||
if(StringHelper.isEmpty(vo.getCreator())){
|
||||
if(StringHelper.isEmpty(vo.getInputUser())){
|
||||
return ServerResponse.createErroe("请填写入库人");
|
||||
}
|
||||
if(StringHelper.isEmpty(vo.getInputDay())){
|
||||
|
|
@ -72,19 +80,67 @@ public class PartInputServiceImpl implements PartInputService{
|
|||
if(list==null || list.isEmpty()){
|
||||
return ServerResponse.createErroe("请上传入库配件");
|
||||
}
|
||||
Long userId= Objects.requireNonNull(UserUtil.getLoginUser()).getUserId();
|
||||
// String userName=UserUtil.getLoginUser().getUsername();
|
||||
String code=getCode();
|
||||
vo.setCode(code);
|
||||
vo.setCreator(userId.toString());
|
||||
vo.setUpdater(userId.toString());
|
||||
AtomicReference<String> isFlag= new AtomicReference<>("1");
|
||||
final int[] inputNum = {0};
|
||||
BigDecimal allPrice = new BigDecimal("0");
|
||||
list.forEach(detail->{
|
||||
inputNum[0] = inputNum[0] +detail.getInputNum();
|
||||
//单价
|
||||
BigDecimal price = new BigDecimal(detail.getPartPrice());
|
||||
if("0".equals(detail.getPartPrice())){
|
||||
isFlag.set("0");
|
||||
}
|
||||
//数量
|
||||
BigDecimal num = new BigDecimal(detail.getInputNum());
|
||||
//总价
|
||||
BigDecimal totalPrice = price.multiply(num);
|
||||
detail.setTotalPrice(totalPrice.toString());
|
||||
allPrice.add(totalPrice);
|
||||
|
||||
long userId= UserUtil.getLoginUser().getUserId();
|
||||
String userName=UserUtil.getLoginUser().getUsername();
|
||||
//int num=mapper.addInputData(vo);
|
||||
|
||||
|
||||
});
|
||||
|
||||
vo.setAllPrice(allPrice.toString());
|
||||
vo.setInputNum(inputNum[0]);
|
||||
vo.setIsFlag(isFlag.get());
|
||||
int num=mapper.addInputData(vo);
|
||||
if(num>0){
|
||||
List<FileUploadVo> fileList=uploadService.uploadImage(files,vo.getId(),"t_part_input");
|
||||
if(StringUtils.isEmpty(fileList) || fileList.size()!=files.length){
|
||||
return ServerResponse.createErroe("入库失败");
|
||||
}
|
||||
int num2= mapper.addDetails(vo,list);
|
||||
if(num2==list.size()){
|
||||
return ServerResponse.createSuccess("入库成功");
|
||||
}
|
||||
return ServerResponse.createErroe("入库失败");
|
||||
|
||||
}else{
|
||||
return ServerResponse.createErroe("入库失败");
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return null;
|
||||
return ServerResponse.createErroe("入库失败");
|
||||
}
|
||||
|
||||
|
||||
public String getCode( ) {
|
||||
int num =mapper.getInputNum();
|
||||
num++;
|
||||
String year= DateTimeHelper.getNowYMD();
|
||||
if(num<10) {
|
||||
return year+"00"+num;
|
||||
}else if(num<100) {
|
||||
return year+"0"+num;
|
||||
}
|
||||
return year+num;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
<mapper namespace="com.bonus.gzgqj.business.bases.mapper.PaTypeMapper" >
|
||||
<!--新增类型-->
|
||||
<insert id="addTypeData" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into pa_type(parent_id, name,remarks,is_active,level)VALUES(#{parentId},#{name},#{remarks},1,#{level})
|
||||
insert into pa_type(parent_id, name,remarks,unit,is_active,level)VALUES(#{parentId},#{name},#{remarks},#{unit},1,#{level})
|
||||
</insert>
|
||||
<update id="updateTypeData">
|
||||
update pa_type set name=#{name},remarks=#{remarks} where id=#{id}
|
||||
update pa_type set name=#{name},remarks=#{remarks},unit=#{unit} where id=#{id}
|
||||
</update>
|
||||
<update id="deleteTypeData">
|
||||
update pa_type set is_active=0 where id=#{id}
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
</select>
|
||||
<select id="getTypeDetails" resultType="com.bonus.gzgqj.business.bases.entity.PaTypeVo">
|
||||
select pt.id,pt.parent_id parentId,pt.name,pt.num,pt1.name parentName,
|
||||
pt.price,pt.unit,pt.weight,pt.is_consumables ,
|
||||
pt.price,pt.unit ,pt.weight,pt.is_consumables ,
|
||||
pt.remarks,pt.is_active ,pt.level,pt.warn_num
|
||||
FROM pa_type pt
|
||||
left join pa_type pt1 on pt.parent_id=pt1.id and pt1.`level`=2 and pt1.is_active=1
|
||||
|
|
|
|||
|
|
@ -1,6 +1,24 @@
|
|||
<?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.bonus.gzgqj.business.bases.mapper.PartInputMapper" >
|
||||
<insert id="addInputData" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into t_part_input(
|
||||
code,creator,create_time,is_flag,remark,updater,update_time,
|
||||
all_price,input_day,input_num,input_user
|
||||
)values (#{code},#{creator},now(),#{isFlag},#{remark},#{updater},now(),
|
||||
#{allPrice},#{inputDay},#{inputNum},#{inputUser})
|
||||
</insert>
|
||||
<insert id="addDetails">
|
||||
insert into (
|
||||
put_id,part_id,part_type,part_name,part_model,part_unit,input_num,part_price,
|
||||
total_price,vender_id,vender_name) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{param.id},#{item.partId},#{item.partType},#{item.partName},
|
||||
#{item.partModel},#{item.partUnit},#{item.inputNum},#{item.partPrice},
|
||||
#{item.totalPrice},#{item.vendId},#{item.vendName})
|
||||
</foreach>
|
||||
|
||||
</insert>
|
||||
<!--分页查询-->
|
||||
<select id="findByPage" resultType="com.bonus.gzgqj.business.bases.entity.PartInputVo">
|
||||
select tpi.id,tpi.code,tpi.creator,tpi.input_day inputDay,
|
||||
|
|
@ -19,4 +37,10 @@
|
|||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<!--入库数量-->
|
||||
<select id="getInputNum" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from t_part_input
|
||||
where DATE_FORMAT(create_time,'%Y-%m-%d')=CURRENT_DATE
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue